[squeak-dev] The Inbox: Kernel-dtl.1015.mcz
David T. Lewis
lewis at mail.msen.com
Wed Apr 13 23:09:02 UTC 2016
I would appreciate a review before moving this to trunk.
Background:
In UTCDateAndTime, most things are much faster than the trunk version.
However, DataAndTime equality check did not improve for 32-bit images,
so I ran it under AndreasSystemProfiler. Profiling showed that large
integer equality checks spends time mostly in primDigitCompare, which
is inefficient when only a simple byte comparison is needed.
Here is the performance difference that I see on my system, 32-bit trunk
Spur on Linux:
| a b c d |
a := 7432154326465436. "a big number"
b := a + 1. "low order digit changed"
c := 8432154326465436. "high order digit changed"
d := 7432154026465436. "a digit in the middle changed"
"Base performance in the trunk image"
Time millisecondsToRun: [500000000 timesRepeat: [ a = b ]]. "==> 63733"
Time millisecondsToRun: [500000000 timesRepeat: [ a = c ]]. "==> 63152"
Time millisecondsToRun: [500000000 timesRepeat: [ a = d ]]. "==> 63581"
"Performance after adding LargePositiveInteger>>="
Time millisecondsToRun: [500000000 timesRepeat: [ a = b ]]. "==> 4676"
Time millisecondsToRun: [500000000 timesRepeat: [ a = c ]]. "==> 4883"
Time millisecondsToRun: [500000000 timesRepeat: [ a = d ]]. "==> 4512"
Dave
On Wed, Apr 13, 2016 at 10:57:28PM +0000, commits at source.squeak.org wrote:
> David T. Lewis uploaded a new version of Kernel to project The Inbox:
> http://source.squeak.org/inbox/Kernel-dtl.1015.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-dtl.1015
> Author: dtl
> Time: 13 April 2016, 6:57:22.56608 pm
> UUID: bd849f91-9b00-45c5-b2ab-891b420bde5e
> Ancestors: Kernel-mt.1014
>
> Make large integer equality test be about 13 times faster. Implement #= in LargePositiveInteger, and use digitAt: (primitive 60) for the comparison.
>
> =============== Diff against Kernel-mt.1014 ===============
>
> Item was added:
> + ----- Method: LargePositiveInteger>>= (in category 'comparing') -----
> + = aNumber
> +
> + aNumber class == self class ifTrue: [
> + aNumber size = self size ifFalse: [ ^false ].
> + self size to: 1 by: -1 do: [ :i | (aNumber digitAt: i) = (self digitAt: i) ifFalse: [ ^ false ] ].
> + ^ true ].
> + aNumber isInteger ifTrue: [ ^false ].
> + aNumber isNumber ifFalse: [ ^false ].
> + ^aNumber adaptToInteger: self andCompare: #=!
>
More information about the Squeak-dev
mailing list
|