<div dir="ltr"><div dir="ltr">Hi Levente,</div><div dir="ltr"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I tend to weigh toward a system defined tersely in terms of its own messages, and letting performance emanate from the _design_, as opposed to chasing an extra 5% of execution performance improvement at the expense of<br>
> expressivity of the code.  If the point of that 5% is to "save time", it seems reasonable to consider the time of future readers of the code.<br>
> <br>
> The method, #isAlphanumeric, is a prime example.  Originally, its implementation beautifully matched its definition.<br>
> _____<br>
>     isAlphaNumeric<br>
>         "Answer whether the receiver is a letter or a digit."<br>
>         ^self isLetter or: [self isDigit]<br>
> _____<br>
> <br>
> Compare that to now, a complex, copy-and-pasted "implementation" which is a lot harder to understand and maintain, but only 10% faster in execution.  IMO, that seems past the point of diminishing returns of what a user of<br>
> Smalltalk would expect.<br>
<br>
If #isAlphaNumeric is too complex, then so are #isLetter and #isDigit. <br>
Please revert those as well to the _simple_ implementation and redo your <br>
benchmark.<br></blockquote><div><br></div><div>There's no reason to take my comments personally.  #isLetter looks to be sufficiently uniquely defined -- there's very little that could be factored with #isDigit that would be worthwhile.  But we can disagree about the trade-off of copying those implementations up to #isAlphaNumeric instead of reusing them.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> Having said that, Squeak's speed is sweet, I can appreciate the desire to hyper-optimize at the bytecode level.  Here's Marcel's benchmark with the latest:<br>
<br>
Wasn't it you who considered the weak dictionaries too slow and had to <br>
use a different implementation?<br></blockquote><div><br></div><div>The IdentityDictionary's actually (and, yes, the Weak flavor), back when Squeak's 12-bit #identityHash would result in way too many collisions.  That's an example of what I was saying about letting performance emanate from the _design_ and less from micro-optimizations of the code, to realize a huge gain.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> ___<br>
> ['Hello {1}!' format: { 'Squeak' }] bench.<br>
> <br>
>  '3,450,000 per second. 290 nanoseconds per run. 1.35946 % GC time.'   <--- new<br>
>  '3,820,000 per second. 262 nanoseconds per run. 4.22 % GC time.'     <--- old<br>
> <br>
> 3450.0/3820   0.9031413612565445 <br>
<br>
What if there are multiple substitutions instead of just one? Is it still <br>
just 10 percent slower?<br></blockquote><div><br></div><div>Looks like with the following 100 substitution case, the hit increased to 25%.</div><div>___<br></div>|str values| str := String streamContents: [ : stream | 1 to: 100 do: [ : n | stream nextPutAll: 'Hello {'; nextPutAll: n asString; nextPutAll: '} Squeak!  ' ] ].<br>values := (1 to: 100) collect: [ : each | each asWords ].<br>[str format: values] bench.<br><div><br></div><div> '83,800 per second. 11.9 microseconds per run. 2.4 % GC time.'  "<-- old"<br> '63,100 per second. 15.9 microseconds per run. 1.85926 % GC time.' "<-- new"<br></div><div>___</div><div><br></div><div>Overall, I expected it to be a little bit slower, but in exchange for more power.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> Looks like about a 10% hit for this example.  Maybe it could be improved, but I doubt by very much.  Unfortunately using #basicAt: isn't convenient when alphanumeric tokens are possible.  <br>
<br>
Why limit the tokens to alphanumeric ones? Why am I not allowed to write <br>
the following?<br>
<br>
        '{foo_bar}' format: ({ 'foo_bar' -> 1 })<br></blockquote><div><br></div><div>To maximize speed and simplicity.  Underscore is a great idea, but checking for it exacts another few % speed hit.  I think it's worth it, how about you?</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Also, why do I get an error when I try this?<br>
<br>
        '{0x1}{0x2}' format: ({ '0x1' -> 1. '0x2' -> 2 } as: Dictionary)<br></blockquote><div><br></div><div>As with Symbols in Squeak and identifiers in many languages, the alphanumeric tokens are limited to beginning with an alphabetic character.  Starting with a numeral will cause the optimized code to assume you're using numeric tokens.</div><div><br></div><div>Please don't take offense to my priorities of coding.  I certainly appreciate yours.  If this feature isn't worth the performance hit, let me know.  I don't think it will ever be noticeable, but I'm happy to revert it if it is (even happier if you're able to work your magic to make it even faster).</div><div><br></div><div>Regards,</div><div>  Chris</div></div></div>