The Timing of Time

Brent Pinkney brent.pinkney at aircom.co.za
Thu Apr 13 08:04:42 UTC 2006


On Thursday 13 April 2006 09:37, Avi Bryant wrote:
> On Apr 13, 2006, at 12:08 AM, goran at krampe.se wrote:
> > PS. But I do think the official Squeak should make a choice - there
> > should be a "Squeak standard". And of course, we did that pretty
> > recently - Chronology. Would be interesting to hear more about
> > pros/cons. :)
>
> 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.  More than once, our
> profiling has led us to some part of Chronology that was an order of
> magnitude or two slower than it needed to be.  The most recent
> example of a couple of days ago was DateAndTime>>hash - try sticking
> a few thousand dates into a Set and you'll see what I mean.  That can
> be sped up, in some cases, by a simple optimization in
> DateAndTime>>asUTC:
>
> asUTC
> 	^ offset isZero
> 		ifTrue: [self]
> 		ifFalse: [self utcOffset: 0]
>
> Avi

Hi Avi,

Do not forget to use this improvment that Dan Ingalls submitted:

DateAndTime>>dayOfYear
	"This code was contributed by Dan Ingalls. It is equivalent to the terser
		^ jdn - (Year year: self year) start julianDayNumber + 1 but much quicker."

	| monthStart |
	^ self dayMonthYearDo:
		[ :d :m :y |
			monthStart := #(1 32 60 91 121 152 182 213 244 274 305 335) at: m.
			(m > 2 and: [ Year isLeapYear: y ])
				ifTrue: [ monthStart + d ]
				ifFalse: [ monthStart + d - 1 ]]
!

This is, I believe already in the 3.9 image.

Brent



More information about the Squeak-dev mailing list