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

Andreas Raab andreas.raab at gmx.de
Sun May 1 06:43:46 UTC 2005


Geesh. This "bechmark" is as bogus as it gets. Unbelievable. Try it with 
polymorphic receivers (say more than 3 different ones to kill the cache 
performance for a change). Seriously, benchmarks should be defined by 
people who understand what they are measuring.

My comparison was based on the fact that the microbenchmarks show that 
*on average* the difference between bytecodes and sends is roughly 1:30. 
On *average* mind you, not on a totally bogus, 
send-the-same-message-to-the-same-object-with-guarantueed-cache-hit 
"benchmark".

And besides, system performance has very little to do with these 
micro-benchmarks anyway - I don't buy *any* of those points made about 
how horrible it is that we aren't aware about how much time we "waste" 
when sending a message instead of utilizing a bytecode.

Let's stop this pointless discussion, shall we?

   - Andreas

Peace Jerome wrote:
> 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