<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 15, 2016 at 5:57 PM Victor Stinner <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2016-09-15 10:02 GMT+02:00 INADA Naoki <<a href="mailto:songofacandy@gmail.com" target="_blank">songofacandy@gmail.com</a>>:<br>
> In my environ:<br>
><br>
> ~/local/python-master/bin/python3 -m timeit -s "d =<br>
> dict.fromkeys(range(10**6))" 'list(d)'<br>
<br>
Stooooop! Please stop using timeit, it's lying!<br>
<br>
* You must not use the minimum but average or median<br>
* You must run a microbenchmark in multiple processes to test<br>
different randomized hash functions and different memory layouts<br>
<br>
In short: you should use my perf module.<br>
<a href="http://perf.readthedocs.io/en/latest/cli.html#timeit" rel="noreferrer" target="_blank">http://perf.readthedocs.io/en/latest/cli.html#timeit</a><br>
<br></blockquote><div><br></div><div>I'm sorry.  Changing habit is bit difficult. I'll use it in next time.</div><br class="inbox-inbox-Apple-interchange-newline"><div>I ran microbench 3~5 times and confirm the result is stable before posting result.</div><div>And when difference is smaller than 10%, I don't believe the result.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The memory layout and the hash function have a major important on such<br>
microbenchmark:<br>
<a href="https://haypo.github.io/journey-to-stable-benchmark-average.html" rel="noreferrer" target="_blank">https://haypo.github.io/journey-to-stable-benchmark-average.html</a><br>
<br></blockquote><div><br></div><div>In this microbench, hash randomization is not important, because key</div><div>of dict is int.</div><div>(It means iterating dict doesn't cause random memory access in old dict</div><div>implementation too.)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> Both Python is built without neither `--with-optimizations` or `make<br>
> profile-opt`.<br>
<br>
That's bad :-) For most reliable benchmarks, it's better to use<br>
LTO+PGO compilation.<br></blockquote><div><br></div><div>LTO+PGO Â may make performance of `git pull && make` unstable.</div><div>PGO clean build takes tooo long time for such a quick benchmark.</div><div>So I don't want to use PGO in such a quick benchmark.</div><div><br></div><div>And Python doesn't provide way to use LTO without PGO....</div><div><br></div></div></div>