apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pane <bri...@apache.org>
Subject Re: Why not POSIX time_t?
Date Mon, 15 Jul 2002 04:24:09 GMT
Justin Erenkrantz wrote:

>On Sun, Jul 14, 2002 at 07:42:09PM -0700, Brian Pane wrote:
>  
>
>>It's a little more efficient if you put the result in
>>a struct rather than a scalar, but you still have to do
>>the carry from the seconds field to the microseconds field
>>if time1.tv_usec < time2.tv_usec.  Minimally, subtraction
>>of the structs requires two subtractions, a comparison,
>>and a conditional branch.
>>    
>>
>
>Now, what are we more likely to do:
>
>1) Retrieve the seconds from the time value
>2) Subtract two time values
>
>For httpd, I'm pretty sure what the answer is.  And, I believe the
>answer to that dictates our time structure.  -- justin
>  
>

The answer is probably:
  3) Pass a time as an argument to a function

And that's one of the areas where the 64-bit scalar representation
has advantages over the struct.  The struct is at least a 96-bit
quantity:
   - 64 bits for the seconds (to avoid a Y2038 problem)
   - 32 bits for the microseconds
The code that the compiler generates to pass these structs
around, even on a 64-bit CPU, will be more inefficient than
that code that it can generate to pass a 64-bit busec scalar.
This will erode the performance advantage that you might
otherwise expect from being able to extract seconds from
the start of a struct with no additional opcodes.

--Brian



Mime
View raw message