[Mono-dev] Alternative to calculating Elapsed time using QueryPerformanceCounter
nikhil sehgal
nikhil.jiet at gmail.com
Mon Apr 10 08:20:58 UTC 2017
QueryPerformanceCounter returns a monotonically increasing tick count.
Current we are using above mentioned Performance Counter and Performance
Frequency using “Kernel32.dll”.
Basically we use QueryPerformanceCounter to get a high resolution timer
value before and after the event you want to time.
Then use QueryPerformanceFrequency to get the number of ticks per second.
Divide the time difference by this value to convert the value to seconds.
alternatively we have thought to use stopwatch to achive same on Linux
using mono framrwork
Alternative way of Performance Counter and Performance Frequency by using
System. Diagnostics. Following are the code to find the same.
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();
MyFunction();
watch.Stop();
double elapsedMs = watch.ElapsedTicks;
Console.WriteLine(elapsedMs);
However result we are getting on windows using QueryPerformanceCounter and
on Linux using Stopwatch have different precision Please find screenshot
below.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20170410/40557d51/attachment.html>
More information about the Mono-devel-list
mailing list