delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/15/05:06:32

Date: Sun, 15 Jun 1997 12:05:02 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Ben N Shadwick <bshadwick AT juno DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: rawclock() and other time.h functions
In-Reply-To: <19970612.170431.8822.3.bshadwick@juno.com>
Message-ID: <Pine.SUN.3.91.970615120250.14561L-100000@is>
MIME-Version: 1.0

On Thu, 12 Jun 1997, Ben N Shadwick wrote:

> >The bug is in the docs, not in the code.  The next release will fix
> >the docs.
> 
> I don't believe you.

Why?  Did I ever lie to you in the past?

> What good does a bunch of functions that always
> return zero the first time you call them do (besides giving you four
> hundred ways to measure how fast your program is)?

There are a lot of use for such function that only need relative
times.  Anyway, I didn't write that function, so I can't give you the
real reason why it was designed this way.  When this inconsistency was
first reported, DJ Delorie said that the docs were in error, not the
code.

> IMHO, they have many
> more applications when implemented the way the docs describe them - if
> you need to use it the "returns-zero-the-first-time" way, just set some
> variable equal to it and subtract its value to achieve the same effect.
> On the other hand, if you need a quick way to know the number of seconds
> (or clock ticks) since midnight, you have that too.

It works both ways: you can always call any of the functions that
return calendar time and the number of seconds since midnight to the
values returned by `rawclock'.

> Like Nate said, it only has a 1 second accuracy that way (not very
> desirable)

Do you really need to start a random sequence more than once per
second?  Anyway, if you do, you can call `gettimeofday' (which has a
microsecond resolution).  Another way to solve this problem is to call
the random generator repetitively until it returns a value different
from the previously-used one.

- Raw text -


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