5 % is cool in such scenario. Thanks levente. I believe in small speed ups and you show that.
Stef On May 24, 2010, at 10:47 PM, Levente Uzonyi wrote: > On Mon, 24 May 2010, Lukas Renggli wrote: > >>> IMHO 4 is the most readable and it is the fastest in Pharo/Squeak at the >>> moment, so that should be preferred in core packages. >> >> It should not be preferred or changes unless you can prove a real >> performance benefit. I still haven't seen a single realistic benchmark >> with real code (from Pharo, Seaside, Pier, ...) where you can measure >> a real difference between these 4 variants. > > Well, just replace all uses of == nil and #ifNil:, etc with isNil and isNil > ifTrue: etc. Then get some benchmarks which you accept as realistic and run > them in both images. > > For now I can only show a microbenchmark that I evaluated in > PharoCore-1.1-11367 on my slow machine: > > Original: > (1 to: 5) collect: [ :run | > FileStream readOnlyFileNamed: (SourceFiles at: 1) name do: [ :file | > [ [ file next isNil ] whileFalse ] timeToRun ] ] > #(9928 9733 9753 9703 9711) > > Then I replaced the #isNil send to == nil: > > (1 to: 5) collect: [ :run | > FileStream readOnlyFileNamed: (SourceFiles at: 1) name do: [ :file | > [ [ file next == nil ] whileFalse ] timeToRun ] ] > #(9214 9301 9419 9273 9285) > > Not bad 4.8% faster. Then I replaced the line > character1 isNil ifTrue: [^ nil]. > with > character1 ifNil: [^ nil]. > in UTF8TextConverter >> #nextFromStream:. > > (1 to: 5) collect: [ :run | > FileStream readOnlyFileNamed: (SourceFiles at: 1) name do: [ :file | > [ [ file next == nil ] whileFalse ] timeToRun ] ] > #(8947 8779 8814 8845 8810). > 5% faster than the previous. > > Removing 2 #isNil sends from the tight loop gave ~10% speedup. > > > Levente > >> >> >>> 1 just looks bad, I can't imagine an OODB that doesn't map it's "null >>> object" directly to nil, otherwise #= will be asymmetric: >>> null = nil -> true >>> nil = null -> false >> >> That's not the problem. The problem is when you have proxy objects >> then all these inlined an shortcut variants fail miserably. >> >> Lukas >> >> -- >> Lukas Renggli >> www.lukas-renggli.ch >> >> _______________________________________________ >> Pharo-project mailing list >> Pharo-project@lists.gforge.inria.fr >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > Pharo-project@lists.gforge.inria.fr > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project