[Mono-list] A substitute to the high definition clock QueryPerformanceCounter ?

Paolo Molaro lupus@ximian.com
Mon, 26 Apr 2004 15:58:17 +0200

On 04/23/04 HannibAl Bundie wrote:
> I need a high definition clock but unfortunately,  that which I used on 
> windows (QueryPerformanceCounter / QueryPerformanceFrequency) is dependent 
> on this OS.
> So is there an alternative (in Mono.Posix or other stuff like this) to 
> QueryPerformance ?

On unixy systems you should likely use gettimeofday ():

        struct timeval {
                public int seconds;
                public int useconds;

        [DllImport ("libc")]
        static extern int gettimeofday (out timeval tv, IntPtr unused);

That works on Linux/x86 and should work on many other systems as well (on
some 64 bit systems the types may be longs, in others the order may be
different, but both things can be easily checked at runtime if needed).


lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better