Timing Code line by line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all, i was wondering if its possible to 'time' every single line of code
then output the the results as in a profiler i.e.

Time Line of code
22ms If... etc;
32ms i++;
..... ....

i know you can time a loop or whatever through the Start -> do loop -> stop
proceedure i.e

Start timer
Do....
.....
....
Stop timer

etc

But im looking for a method to time each and every line of code in a
program, either at compile time or at run time.

hope someone has an idea on how to do this, i am perticularly looking for a
code example so i could get the general gist of doing it.

I dont mind if the results are in C# or VB.net

thanks all for your help

Nick
 
The CLR has all sorts of profiling API's to allow for just this. However,
you'd be far better off looking for a profiling tool. There is one called
NProf which is open source, and I use DevPartners free Community Edition
Profiler.
 
Can you suggest any APIs please?... i jsut downloaded NProf so gunna start
scrolling through that, thanks for the suggestion. but if u could suggest
some APIs that would be great.

Thanks alot, Nick
 
The APIs are quite nasty. they're COM interfaces, and you'll have to use
unmanaged code to access them. On my computer the documentation is located
at:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers
Guide\docs\Profiling.doc. There's a samples at:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers
Guide\Samples\profiler
 
Dam, im not a strong C++.net programmer, is there none that are specific to
the c# language, or will i have to convert them over?

thanks nick
 
Back
Top