Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-09-19 10:20:24


John Maddock wrote:

>First of all, let me thank everyone who has taken the time to read
and
>comment on my regular expression proposals, I don't think that I
would
>dissagree with any of the comments, so I'll concentrate on some
"proof of
>principal" generics first and move on to the complex stuff later.
>
>Now for the stupid question:
>
>What exactly is the problem in implementing timer::elapsed_max() ?
>
>Provided time_t is an integral type, then doesn't something like:
>
>(double)numeric_limits<time_t>::max() / (double)CLOCKS_PER_SEC
                        ^^^^^^
I think you meant clock_t rather than time_t.

>give a reasonable value.

That assumes that the maximum value for clock_t is the same as
numeric_limits<clock_t>::max(). That is not specified in the C++, C,
or C9X standards, so there is no portable way to know if it is
correct.

I guess you could just assume it is correct - it probably is for most
platforms.

>However from the standard it seems as if clock_t can be a floating
point
>type, in which case I accept estimation becomes more difficult,
would:
>
>numeric_limits<time_t>::max() - clock() / (double)CLOCKS_PER_SEC
>
>give a reasonable estimation?
>
>
>Finally, a member,
>
>static double timer::elapsed_min();
>
>would be a very useful addition, by default returns: (double)1/
>(double)CLOCKS_PER_SEC

I will add it.

--Beman


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