delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/15/12:33:24

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: rawclock() and other time.h functions
Date: 15 Jun 1997 12:18:12 GMT
Organization: Oxford University, England
Lines: 32
Message-ID: <5o0mi4$nv1@news.ox.ac.uk>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970612181819 DOT 9257V-100000 AT is> <19970612 DOT 170431 DOT 8822 DOT 3 DOT bshadwick AT juno DOT com>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ben N Shadwick (bshadwick AT juno DOT com) wrote:

: I don't believe you. 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)? 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.

Making them behave as the docs say would render them useless (almost) for
timing purposes. Consider what would happen if your program was running at
midnight - mysterious bugs with the timing would occur. Spooky.

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

void randomise()
{
 int a;
 uclock();
 a=time(0);
 while (a==time(0));
 srandom(uclock());
}

I think that should be pretty unpredictable as a starting point :)

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

- Raw text -


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