Adding a new imediate type
Yoshiki Ohshima
yoshiki at squeakland.org
Wed Jan 11 22:04:37 UTC 2006
So, I made a "noFill" variant of newWithArg primitive, and wrote a
few copying methods that calls it. The good examples, such as this:
-------------------------------
str _ String new: 10000.
[100000 timesRepeat: [str copyFrom: 2 to: 10000]] timeToRun
=> 2110 2105
[100000 timesRepeat: [str copyNoFillFrom: 2 to: 10000]] timeToRun
=> 1653 1649
-------------------------------
gives me 22% improvement, and this one:
-------------------------------
bits _ Display asFormOfDepth: 32.
"bits extent => 960 at 700"
[100 timesRepeat: [bits copy: (100 at 100 extent: 500 at 500)]] timeToRun
=> 274 274
[100 timesRepeat: [bits copyNoFill: (100 at 100 extent: 500 at 500)]]
TimeToRun
=> 196 195
-------------------------------
gives me 29% improvement. A bit more realistic one:
-------------------------------
[10 timesRepeat: [bits unhibernate. bits hibernate]] timeToRun
=> 4531 4527
[10 timesRepeat: [bits unhibernateNoFill. bits hibernateNoFill]]
timeToRun
=> 4449 4449
-------------------------------
only gives me 2% improvement... However, it is still worth it.
By the way, the direct benchmark, which is too loop intensive to say
anything, is:
-------------------------------
[10000000 timesRepeat: [String new: 100]] timeToRun
=> 5359 5422
[10000000 timesRepeat: [String newNoFill: 100]] timeToRun
=> 5047 5047
[100 timesRepeat: [String new: 10000000]] timeToRun
=> 23781 23765
[100 timesRepeat: [String newNoFill: 10000000]] timeToRun
=> 21750 21734
-------------------------------
So it is about 7%-9% for such String creation.
My "noFill" primitive does fill out the newly created object if it
is a pointer object, so it is quite possible to replace the
#copyFrom:to: (for example) for at SequenceableCollection.
-- Yoshiki
More information about the Squeak-dev
mailing list
|