Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to find my logic execution time in c#.net?
Posted

Hi
You will have to use the timer, Start it before the logic and stop it after the logic. .NET has an inbuilt timer.

Jacques
 
Share this answer
 
Comments
OriginalGriff 16-Nov-12 7:50am    
This is not a good solution - both the Timer classes have poor resolution and are not intended for accurate measurement. Use the Stopwatch class instead.
Look at the Stopwatch class[^] - it's easy to use and provides accurate timing.
This Tip shows it in use to measure the execution time of various different ways of counting lines in a string: Counting lines in a string[^]
 
Share this answer
 
Comments
Jacques Loubser 16-Nov-12 7:56am    
If you are after accuracy, use the Direct X timer. It is a single timer that is accurate to 1/1000000000th of a second. But then you will have to package Direct X with your distribution...
OriginalGriff 16-Nov-12 8:08am    
Um. Probably not that accurate in reality. It uses the system performance query and is as accurate as the hardware on any specific computer lets it be. Just because it reports in nanoseconds, does not mean it is accurate to the nanosecond!
In fact, it can be less accurate than a System.Trheading.Timer on systems where the processor speed can be varied according to load...
Jacques Loubser 16-Nov-12 8:14am    
This timer is used for the graphics timing, but I agree, you can't be more accurate than the hardware permits.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900