Better way to write this method with this pattern?

Posted by Slorthe on Stack Overflow See other posts from Stack Overflow or by Slorthe
Published on 2014-06-09T02:42:13Z Indexed on 2014/06/09 3:26 UTC
Read the original article Hit count: 90

Filed under:

I have written a lot of methods and I want to time how long it takes for them to run.

     public void myMethod(){
         startTiming();
         doLotsOfStuff();
         stopTiming();
     }

I am not only timing, I am also doing some other stuff before AND after the doLotsOfStuff() method.

I was wondering if there is a better/smarter way to do this in C# to achieve lesser amount of lines/coding needed for this particular pattern.

© Stack Overflow or respective owner

Related posts about c#