The Timing of Time

David T. Lewis lewis at mail.msen.com
Thu Apr 13 11:13:30 UTC 2006


On Thu, Apr 13, 2006 at 11:47:56AM +0200, Bert Freudenberg wrote:
> 
> Am 13.04.2006 um 11:15 schrieb Andreas Raab:
> 
> > Avi Bryant wrote:
> >> What I can contribute here is that the performance benefits are  
> >> more than just theoretical - the poor performance of the  
> >> Chronology package has been responsible for a significant  
> >> percentage of the bottlenecks in our production code recently.
> >
> > Heh. "me too". In my case it was printing. Would be interesting to  
> > see how long a #printString takes for either one.
> 
> For me, it was the space inefficiency. I ran into this when trying to  
> put many monticello version infos into a database. MC stores a Date  
> and a Time separately, for historic reasons. Dates used to be just a  
> simple offset in days. Nowadays, they have a start, a timezone  
> offset, and a duration, each of which is a full object, and all are  
> in nanosecond precision. So we have 4 times as many objects, taking  
> like 10 times the space necessary.
>

I learned a couple of things in the course of implementing time zones
(TimeZoneDatabase on Squeak Map) that can have a big impact on performance.

In order to implement time zones correctly, I created class PointInTime.
This represents time independently of calendars and time zones, and
(on Squeak) uses ScaledDecimal for its numeric representation. It is
also tied in to Squeak's DateAndTime and TimeZone to allow conversions
back and forth, and to allow DateAndTime and Duration to use the time
zones in the time zone database.

Here's what I learned:

1) ScaledDecimal is a very nice way to represent time magnitudes. It has
unlimited precision, and is computationally efficient because time values
tend to be simple integer values derived either from user input or from
the hardware clock on your computer.

2) Both DateAndTime and TimeZone can be thought of as the external
representation of a PointInTime. They are meaningful to people, but it
is difficult to get them to behave like magnitudes (certainly this is the
case if you want them to be both and correct *and* fast). If you want to
do a lot of time and duration calculations (for example in Montecello),
it is preferable to do the calculations with e.g. PointInTime, and to
present the results (human readable time stamps) as DateAndTime.

Dave



 



More information about the Squeak-dev mailing list