Click here to Skip to main content
13,091,894 members (62,426 online)
Rate this:
Please Sign up or sign in to vote.
See more:
how to find my logic execution time in
Posted 16-Nov-12 1:40am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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[^]
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100