<div dir="ltr">Hi Levente,<br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 20, 2014 at 8:24 AM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Cool. I think the spaceship operator for strings should use #compare:with:collated: to save a comparison in the most common case.<br>
<br>
The performance of symbols would be close to dyadic blocks, if it were cheap and easy to create a block on the fly.<br></blockquote><div><br></div><div>I don&#39;t know what cheap enough in this case is but Spur is over 5 times faster at creating blocks than the existing Cog V3 VM:</div><div><br></div><div><br></div><div>[1 to: 1,000,000,000 do: [:i| [nil class]]] timeToRun</div><div><br></div><div>Spur: 5,950ms</div><div>Cog: 31,951ms</div><div><br></div><div>31951 / 5950.0                 5.37</div><div>5950 - 31951 / 319.51    -81.4%</div><div><br></div><div>So ignoring the loop overhead, Spur creates a block in less than 6 nanoseconds on a 2.2GHz MBP Core i7.</div><div><br></div><div><br></div><div>A slightly more realistic example which creates a new home context for every block created is</div><div><br></div><div><div><br></div><div>[1 to: 10,000,000 do: [:i| [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value. [[nil class]] value.]] timeToRun </div><div><br></div><div>Spur: 2,568ms</div><div>Cog: 11,601ms<br></div><div><br></div><div>11601 / 2568.0 4.51752336448598</div><div>2568 - 11601 / 116.01 -77.8639772433411</div></div><div><br></div><div>So here Spur creates two closures and a context in 2.568 / 100,000,000 = 26 nsecs, compared to 160 for Cog V3.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Levente<br>
<br>
On Fri, 19 Sep 2014, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nicolas Cellier uploaded a new version of Collections to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Collections-nice.582.mcz" target="_blank">http://source.squeak.org/<u></u>trunk/Collections-nice.582.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-nice.582<br>
Author: nice<br>
Time: 19 September 2014, 10:22:13.338 pm<br>
UUID: 52a598f1-224e-4649-a95f-<u></u>4e78547b5ed5<br>
Ancestors: Collections-nice.581<br>
<br>
Port TAG-SortFunctions of Travis Griggs from Cincom public store - version (11,tgriggs)<br>
<br>
Note that no collation policy were used for String.<br>
The spaceship operator &lt;=&gt; is also required in Kernel-Numbers.<br>
<br>
See also the blog <a href="http://objology.blogspot.fr/2010/11/tag-sortfunctions.html" target="_blank">http://objology.blogspot.fr/<u></u>2010/11/tag-sortfunctions.html</a><br>
and <a href="http://objology.blogspot.fr/2010/11/tag-sortfunctions-redux.html" target="_blank">http://objology.blogspot.fr/<u></u>2010/11/tag-sortfunctions-<u></u>redux.html</a><br>
<br>
Note about the cost of these sort functions:<br>
as shown by this mini-bench on cog, using a Symbol costs a bit more (perform:) than a block activation, and monadic block a bit more than dyadic one because activated twice more, but it seems acceptable to me with regard to the great simplification and expressiveness of code :<br>
<br>
| collec1 collec2 collec3 |<br>
collec1 := (1 to: 200000) collect: [:i | 1000000 atRandom-500000].<br>
collec2 := collec1 copy.<br>
collec3 := collec1 copy.<br>
{<br>
[collec1 sort: [:a :b | a abs &lt; b abs]] timeToRun.<br>
[collec2 sort: [:e | e abs] ascending] timeToRun.<br>
[collec3 sort: #abs ascending] timeToRun.<br>
}<br>
#(345 532 912)<br>
<br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>