« Lessons from Simple Web Service Accessing SQL | Main | System.Environment.UserInteractive & WebService »

Execution Timing, DateTime Ticks Resolution

The Ticks property of a TimeSpan produced by subtracting two DateTime.Now value has a resolution of 156247.

There are 10,000,000 ticks per second (TimeSpan.TicksPerSecond), so the resolution is 15.6247 milliseconds.

The Environment.TickCount property counts millisecond ticks and has a resolution of between 15 and 16 milliseconds.

Modified an example of using QueryPerformanceCounter Win32 API to create a high resolution timer for use in C#.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)