delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/11/04/07:38:43

Date: Sun, 4 Nov 2001 14:34:25 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alex Vinokur <alexvn AT bigfoot DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Getting high resolution time
In-Reply-To: <3BE52F3B.C4129F05@bigfoot.com>
Message-ID: <Pine.SUN.3.91.1011104142855.19695A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 4 Nov 2001, Alex Vinokur wrote:

> > Then you should abandon hope to have an accurate timing: Windows has its
> > own ideas about what you need.
> >
> > Our `uclock' does a fairly good job on Windows as well, but be prepared
> > to some surprises.
> 
> I would like to make clear this point for Windows98 and gpp-2.95.3
> 
> I have some function foo().
> I would like to measure its average cost-time in nanoseconds, something like
> :
> 
> start = ????
>           for (i = 0; i < iters; i++)
>                foo ();
> end = ????
> printf("Avg time = %lld nsec\n", (end - start) / iters);
> 
> Is it possible ?

You didn't say what accuracy (as opposed to resolution) do you want this 
information.  Without accyracy requirements, any answer is meaningless.

`uclock' works with sub-microsecond resolution, but I doubt if its 
accuracy, especially on Windows is better than a few milliseconds.

OTOH, you can always make that loop of yours iterate more times, so that 
any such lack of accuracy is made negligible.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019