Timing Code line by line

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
 
S

Sean Hederman

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.
 
G

Guest

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
 
S

Sean Hederman

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top