Reality speed check. isNil vs. == nil is half fast.

Peace Jerome peace_the_dreamer at yahoo.com
Sun May 1 05:05:40 UTC 2005


Some comments andreas made got me curious as to how
much speed was given up for correctness.

So I did a little test.
foo isNil vs. foo == nil .

My result seem to show that former is half as fast as
the latter.


After I realized I had to do a control to eliminate
the time spent looping from the comparison. And I
repeated the test ten times in each loop so the
looping time didn't swamp the out come.

1000000 timesRepeat: [. . . . . . . . . ]]

For a G3 imac running under OS9.1 my results were
control: 900
isNil     3000
== nil   2000

Once the control was subtracted out the time factor
was about 2::1  regardless of the value of foo.

If you want to try this on your system the text of the
test was:



[ { nil . true  . false . Morph new } collect: [ :foo
| {
		[1000000 timesRepeat: [. . . . . . . . . ]] .
	[1000000 timesRepeat: [foo isNil . foo isNil . foo
isNil . foo isNil . foo isNil . foo isNil  . foo isNil
. foo isNil . foo isNil . foo isNil]] .
[1000000 timesRepeat: [ foo == nil . foo == nil . foo
== nil . foo == nil . foo == nil . foo == nil . foo ==
nil . foo == nil . foo == nil]] } collect: [
:testBlock | testBlock timeToRun ] ] ] value collect:
[     :results | results second - results first /
(results third - results first ) asFloat ]

and my results for this example were: 


#(2.03679245283019
 2.051643192488263
 2.058878504672897
 2.06578947368421) 

This is not a conclusive indication of why squeak is
now slower.  It is an indication that more examination
will be useful.  A lot of  inner loop stuff was
changed without regard for the speed impact.


Yours in service, Jerome Peace





		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs



More information about the Squeak-dev mailing list