Mail Archives: djgpp/1996/02/28/07:27:44
On Wed, 28 Feb 1996, Erik Luijten wrote:
> The accuracy does not have be too high: one second would be ok, 0.01 second
> would be perfect.
In that case, I don't think you should care about mode switches: they
typically eat up about 1000 CPU cycles (30 microseconds on a 486/33).
> Why do you say: for anything as long as a few hours, if clock() only wraps
> after ca. 24 hours?
Because I don't recommend to get anywhere near the wrap-around.
> gettimeofday() seems ok, but doesn't it require a switch to real mode?
Yes, it does (it calls a DOS function), but I don't think you should
worry about that for your resolution, see above.
> If so, is there any other timer function (resolution see above) which does
> not require this switch?
clock() doesn't switch to real mode (it just peeks at a certain address
in the BIOS data area). If you need to measure time for longer than 24
hours, you can augment clock() with gettimeofday() (which you can then
call once every 24 hours or so).
- Raw text -