Need help avoiding LargeInteger>>*
Bob Arning
arning at charm.net
Fri Mar 7 11:43:29 UTC 2003
On Thu, 6 Mar 2003 22:21:24 -0800 (PST) Chris Muller <afunkyobject at yahoo.com> wrote:
>"32-bit bench"
>|ba|
>ba _ ByteArray new: 8.
>ba maUint: 32 at: 0 put: (0 to: SmallInteger maxVal) atRandom.
>[ ba maUint: 32 at: 0 ] maBench '243124.975004999 per second.'
>
>"64-bit bench"
>|ba|
>ba _ ByteArray new: 8.
>ba maUint: 64 at: 0 put: (SmallInteger maxVal to: (2 raisedTo: 64)) atRandom.
>[ ba maUint: 64 at: 0 ] maBench '13085.18296340732 per second.'
>
>Wow, that's a tremendous difference! Unfortunately MagmaCollections, by nature
>of their design, need to read a LOT of 64-bit sized numbers.
>
>I looked at unsignedLongAt:bigEndian: and noticed the comment, "Minimize
>LargeInteger arithmetic". Good idea! Unfortunately, I just don't have the
>math training to understand how this bitShifting is being applied that I may
>copy its premise and arrive at the correct answer for 64-bit numbers.
Chris,
Here are a couple of 64-bit snippets. The first seems 2 to 3 times faster and the second 5 to 6 times faster.
======================
^
((self unsignedLongAt: anInteger + 5 bigEndian: false) bitShift: 32) +
(self unsignedLongAt: anInteger + 1 bigEndian: false)
======================
result _ LargePositiveInteger new: 8.
1 to: 8 do: [ :i | result digitAt: i put: (self at: anInteger+i)].
^result
======================
Cheers,
Bob
More information about the Squeak-dev
mailing list
|