[squeak-dev] The Inbox: Chronology-Core-eem.22.mcz

Levente Uzonyi leves at caesar.elte.hu
Sat Jan 12 01:45:17 UTC 2019


On Fri, 11 Jan 2019, David T. Lewis wrote:

> On Sat, Jan 12, 2019 at 12:32:51AM +0100, Levente Uzonyi wrote:
>> Since this thread is about optimization, I just had to chime in.
>> On 64-bit Spur, I measured ~12.5x speedup for #getSeconds which is 
>> impressive. It can increased further by returning the value of the first 
>> expression.
>> Also, I think the calculation is overcomplicated and the whole method 
>> seems to be equivalent to:
>>
>> 	^utcMicroseconds // 1000000 + localOffsetSeconds \\ 86400
>
> The implementation is simpler, but it seems to be a bit slower when I
> measure it (DateAndTime>>asSeconds changed versus Chronology-Core-ul.21
> on 64-bit Spur image).

I guess you meant #getSeconds not #asSeconds.

>
> I tested with this:
>
>  dt := DateAndTime now.
>  Time millisecondsToRun: [ 100000000 timesRepeat: [dt getSeconds ]].

That is really interesting. Do you have numbers?

Here's my benchmark:

| d |
d := DateAndTime now.
(1 to: 5) collect: [ :run |
 	[ 1 to: 100000000 do: [ :i | d getSeconds ] ] timeToRun ]
"Original ==> #(3449 3416 3430 3430 3435)"
"Simplified ==> #(2538 2537 2566 2522 2558)"

I thought that perhaps the negative offset can affect the results, but no, 
it's the same with -7 * 3600 as offset.


Levente

>
> Dave


More information about the Squeak-dev mailing list