Alternative to calculating Elapsed time using QueryPerformanceCounter

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Alternative to calculating Elapsed time using QueryPerformanceCounter

nikhil sehgal

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.

 

 


_______________________________________________
Mono-devel-list mailing list
[hidden email]
http://lists.dot.net/mailman/listinfo/mono-devel-list
Loading...