[Mono-dev] System.Diagnostics.Stopwatch code

Jonathan Resnick jresnick at gmail.com
Tue Feb 28 16:27:22 EST 2006


 
Thanks Jacek!  For now I have decided that DateTime.UtcNow is good enough
for my purposes, and I have created an implementation of
System.Diagnostics.Stopwatch using System.DateTime as the underlying counter
mechanism.  I have attached the code, if anyone is interested or if you want
to include it Mono (I'm not familiar with the process to formally submit
code for Mono), since Mono does not currently have an implementation of this
class.

Jonathan



-----Original Message-----
From: mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Jacek
Blaszczynski
Sent: Saturday, February 25, 2006 6:09 AM
To: 'Brian Crowell'
Cc: 'mono-devel mailing list'
Subject: RE: [Mono-dev] high-resolution timer in Mono?

Hello!

QueryPerformanceCounter() does not provide that high resolution either (only
on 2 or more processor machines resolution is exactly 1 processor tick +/-
call cycles) otherwise its the very same as for DateTime.UtcNow (but not
DateTime.Now - which takes some extra overhead) for details check blogs on
MSDN.  

Please check the link below for project NGmp on sourceforge.net (it's CIL
binding for GMP and MPFR multiprecision numeric libraries) - first files
will be released later today -  for some utility code which will help you on
both Unix/Linux and Windows x86 platforms with very pecise time measurments.
Method GetProcessorTicks() in class Utilities implemements P/Invoke wrapper
for call to native rdtsc x86 instruction which allows for reading internal
x86 processor cycle counter thus providing the ultimate timer resolution
which can be thought of. The measurment overhead is roughly 100 processor
cycles on .NET after compiling assembly with ngen (Mono --aot option does
not work with my code due to some bugs which I am going to file to bugzilla
today). 

http://sourceforge.net/projects/ngmp

Cheers
Jacek

-----Original Message-----
From: mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Brian Crowell
Sent: Friday, February 24, 2006 7:09 PM
Cc: 'mono-devel mailing list'
Subject: Re: [Mono-dev] high-resolution timer in Mono?

Jonathan Resnick wrote:
> What is the best way to do accurate high-resolution timing in Mono on 
> Linux?  I'm basically looking for the equivalent of
> QueryPerformanceCounter() on Windows...  I looked at 
> System.Environment.TickCount, but it has a resolution that "cannot be 
> less than 500 milliseconds", according to the Mono docs.  Is there a 
> high-resolution timer available to Mono?

Not that I know of, but anyone wanting to develop one would want to
implement the new System.Diagnostics.Stopwatch class from .NET 2.0. It was
designed to wrap/replace QueryPerformanceCounter(). I guess a lot of people
wanted that.

--Brian
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Stopwatch.cs
Type: application/octet-stream
Size: 3222 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060228/9e25a6b5/attachment.obj 


More information about the Mono-devel-list mailing list