Hi all!<br>
<br>
Just a short note on some recent updates to <a href="https://github.com/LinqLover/SimulationStudio">SimulationStudio</a> [1]: As of today, there is a new <b>Simulator</b> class that you can inherit from to create <b>different combinable extensions to the default execution behavior</b> (using the Chain of Responsibility pattern). The existing SimulationContext subclasses have been updated to use the new protocol, and I also added <b>two brand-new helpful simulators,</b> LimitSimulator and BenchmarkSimulator.<br>
<br>
Both these simulators aim to <b>abstract execution complexity from real runtime</b> and allow you to define execution constraints that are invariant from the performance of the VM or the local machine. <b>LimitSimulator</b> is the time-abstracted equivalent to <font color="#000080">#valueWithin:onTimeout:</font> to abort execution after a specified number of bytecode steps. <b>BenchmarkSimulator</b> is similar to <font color="#000080">#timeToRun</font>, you can measure the number of bytecode steps and also the number of executed primitives for an arbitrary block. My main use case of BenchmarkSimulator is more reliable, reproducible of comparison of microbenchmarks. For example, when I am optimizing a collection function, I do not any longer need to <font color="#000080">#bench</font> again and again until I have reached a satisfying precision, and if my laptop is working slower the other day because I unpluuged the charger, the benchmark results will still be the same, and when Levente is reviewing my patch, the benchmarks results will still be exactly the same on his machine.<br>
<br>
Try it out yourself!<br>
<br>
<font color="#000000">    </font><font color="#FF0000">BenchmarkSimulator</font><font color="#000000"> </font><font color="#000080">browseRecord:</font><font color="#000000"> [</font><font color="#008000">(</font><font color="#800000">1</font><font color="#000000"> </font><font color="#000080">to:</font><font color="#000000"> </font><font color="#800000">5</font><font color="#008000">)</font><font color="#000000"> </font><font color="#000080">do:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#000000">:</font><font color="#000080">i</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> </font><font color="#000080">i</font><font color="#000000"> </font><font color="#000080">**</font><font color="#000000"> </font><font color="#000080">i</font><font color="#008000">]</font><font color="#000000">].<br>
    </font><font color="#FF0000">BenchmarkSimulator</font><font color="#000000"> </font><font color="#000080">browseRecord:</font><font color="#000000"> [</font><font color="#800000">1</font><font color="#000000"> </font><font color="#000080">to:</font><font color="#000000"> </font><font color="#800000">5</font><font color="#000000"> </font><font color="#000080">do:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#000000">:</font><font color="#000080">i</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> </font><font color="#000080">i</font><font color="#000000"> </font><font color="#000080">**</font><font color="#000000"> </font><font color="#000080">i</font><font color="#008000">]</font><font color="#000000">].<br>
</font>["BenchmarkSimulator.png"]<font color="#000000"><br>
<br>
Or for the execution "step-outs":<br>
<br>
    </font><font color="#808080">|</font><font color="#000000"> </font><font color="#6B6B6B">dict</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"><br>
    </font><font color="#6B6B6B">dict</font><font color="#000000"> </font><b>:=</b><font color="#000000"> Dictionary </font><font color="#000080">new</font><font color="#000000"><br>
        </font><font color="#000080">at:</font><font color="#000000"> </font><font color="#800000">1</font><font color="#000000"> </font><font color="#000080">put:</font><font color="#000000"> </font><font color="#000080">#one</font><font color="#000000">;<br>
        </font><font color="#000080">yourself</font><font color="#000000">.<br>
    </font><font color="#FF0000">LimitSimulator</font><font color="#000000"> </font><font color="#000080">new</font><font color="#000000"><br>
        </font><font color="#000080">stepLimit:</font><font color="#000000"> </font><font color="#800000">139</font><font color="#000000">;<br>
        </font><font color="#000080">evaluate:</font><font color="#000000"><br>
            [</font><font color="#6B6B6B">dict</font><font color="#000000"><br>
                </font><font color="#000080">at:</font><font color="#000000"> </font><font color="#800000">1</font><font color="#000000"> </font><font color="#000080">ifAbsentPut:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#800080">'One'</font><font color="#008000">]</font><font color="#000000">;<br>
                </font><font color="#000080">at:</font><font color="#000000"> </font><font color="#800000">2</font><font color="#000000"> </font><font color="#000080">ifAbsentPut:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#800080">'Two'</font><font color="#008000">]</font><font color="#000000">].<br>
    </font><font color="#008080">"Can you get this test passed? It is possible :-)"</font><font color="#000000"><br>
</font><br>
Installation:<br>
<br>
<font color="#000000">    Metacello </font><font color="#000080">new</font><font color="#000000"><br>
        </font><font color="#000080">baseline:</font><font color="#000000"> </font><font color="#800080">'SimulationStudio'</font><font color="#000000">;<br>
        </font><font color="#000080">githubUser:</font><font color="#000000"> </font><font color="#800080">'LinqLover'</font><font color="#000000"> </font><font color="#000080">project:</font><font color="#000000"> </font><font color="#800080">'SimulationStudio'</font><font color="#000000"> </font><font color="#000080">path:</font><font color="#000000"> </font><font color="#800080">'packages'</font><font color="#000000">;<br>
        </font><font color="#000080">load</font><font color="#000000">.<br>
</font><br>
Have a nice weekend & Carpe Squeak! :-)<br>
<br>
Best,<br>
Christoph<br>
<br>
PS: Stay tuned - further simulation fun is planned to arrive during the coming months! :-)<br>
<br>
<br>
[1] <a href="https://github.com/LinqLover/SimulationStudio">https://github.com/LinqLover/SimulationStudio</a><br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font>