Boost logo

Boost :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2004-04-21 07:37:37


The documentation of boost::timer states that 'The maximum measurable
elapsed time may be as low as 596.5 hours (or even less) ...'.

Well on many 32bit platforms this would probably even be about 71 hours.
Apparantly POSIX requires CLOCKS_PER_SEC to be 10e6, so if clock_t is 32
bit, the maximum of ( clock() / CLOCKS_PER_SEC ) is 4294 seconds.

Because accuracy for clock() is generally about 1 sec, using clock() is
not very usefull for doing timings of short (in time) events. Even more,
for short events, the boost::timer might also influence the timing too
much. So clock() is generally interesting for longer timings (from 10
sec onwards).

But for long events the clock_t wraps around too fast (as mentioned
above). And if you're unlucky that you _start_time = clock() is or a bit
smaller than std::numeric_limits< clock_t >::max() (thus near the
wrap-around point), directly afterwards the expression 'clock() - start'
will result in a negative value.

So I would like to suggest for boost::timer to use std::time_t and use
std::time(NULL) instead of clock() and use std::difftime to calculate
the elapsed time.

toon


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk