[BUG] equivalence between strings and symbols

Stephan Rudlof sr at evolgo.de
Wed Apr 12 02:28:47 UTC 2000


Dan,

Dan Ingalls wrote:
> 
> Stephan -
> 
> >> > >What about completely *removing* Symbol>>= ?
> >> > >
> >> > >Has anybody tried this (without changing other methods)?
> >>
> >> Now, Stephan, the true Squeaker does not ask such a question ;-).
> >
> >So it seems to be, that I'm not a true Squeaker... ;-).
> 
> I wouldn't have teased you if I didn't consider you a consumate Squeaker!
> . . .

Don't worry, there was a smiley at the end of my line...

> 
> >> I say "reasonably" because I have not timed anything yet.  There can be no doubt that = runs slower than == between large strings.  Next time I will time a recompilation of the system before and after -- this should be a good test, since the compiler works fairly heavily with Symbols.
> 
> I found a 14% increase in the time, which is surprising, given your results more like 3%:
>         775090.0 / 677758.0 1.144
> Perhaps disk time could is a factor.
> But see my later result, below, anyway.

For me it is not so easy to get consistent results for long lasting
benchmarks: Linux is a Unix! I don't use other programs while performing
benchmarks and my computer is a standalone one, but nevertheless (first
at all Squeak has to grab its memory, etc.)...

What OS do *you* use?

> 
> >I have made some benchmarks (Linux, Squeak2.8alpha, update: #1974,
> >Morphic), newest first:
> >
> >Smalltalk garbageCollect.
> >[Smalltalk recompileAllFrom: 'Aardvark'.] timeToRun
> >"without Transcript"
> > 727570 "sr suggestion in ST"
> >
> > 735792 "without Symbol>>="
> > 718127 "with Symbol>>="
> > 735708 "without Symbol>>="
> > 718915 "with Symbol>>="
> >
> >My suggestion in ST was:
> >
> >Symbol = anObject
> >        (anObject isMemberOf: Symbol)
> >                ifTrue: [^ self == anObject].
> >        ^ super = anObject
> >
> >Regarding performance it is about in the middle between with and without
> >ordinary Symbol>>=.
> >With a primitive implementation it should be some faster though: but I
> >think priority has to rework the code as suggested by Dan below;
> >probably a primitive is superfluous then.
> 
> Inspired by your suggestion for Symbol =, I improved on it as follows:
> 
> Symbol = anObject
>         self == anObject ifTrue: [^ true].  "Was =="
>         anObject class == Symbol ifTrue: [^ false].  "Was not =="
>         ^ super = anObject
> 

That's it!

> My timing for this version was...
>         680991.0 / 677758.0 1.005
> ...which I consider to be an insignificant degradation.  I'm sure one can come up with examples that show more impact, but I think we're down to a reasonable cost for the benefit of symmetry.

My last benchmarks (don't be irritated by the all over difference to the
times in my last mail, probably the start params...); 'di' stands for
your, 'sr' for my implementation:

Smalltalk garbageCollect.
[Smalltalk recompileAllFrom: 'Aardvark'.] timeToRun
"without Transcript"
 734344 "old: Symbol>>= ^self == anObject"
 736605 "di"
 742707 "sr"
 735630 "di"
 739874 "sr"

(736605 / 734344) asFloat  1.003078938481148

Really a minimal difference (taken the more worse run!)!

BTW: these benchmarks are annoying if you begin to wait for the results,
while forced to leave the computer alone with its work: perhaps I should
buy a second one for these cases ;-)

> 
> Thanks for the challenge.

Thank you for taking the ball...

Greetings,

Stephan

> 
>         - Dan

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list