Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timing Code

Status
Not open for further replies.

Jetski5822

Programmer
Joined
Jan 24, 2005
Messages
10
Location
GB
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, as i am looking for a decent code exampe to start my project, as im not entirely sure where to start.

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

thanks all for your help

Nick
 
I don't know something that do it for each line. I don't think it is possible because your code is changed by the clr to be optimized.
But, if you want to do it for each function (make you functions short), I can recommend on a tool that by adding a attribute to the function, it traces the time of the function.
It works by running a function before and after your function is executed, where you can put some code.
 
There is nprof, a free profiling tool, available at
I haven't used it, but it looks nice.

There are a couple of commercial products available, as well.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top