<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-09-21 0:34 GMT+02:00 Sebastian Graf <span dir="ltr"><<a href="mailto:sgraf1337@gmail.com" target="_blank">sgraf1337@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>[...] The only real drawback I see is that instruction count might skew results, because AFAIK it doesn't properly take the architecture (pipeline, latencies, etc.) into account. It might be just OK for the average program, though.<br></div></div></div></blockquote><div><br></div><div>It really depends on what you're trying to measure: The raw instruction count is basically useless if you want to have a number which has any connection to the real time taken by the program. The average number of cycles per CPU instruction varies by 2 orders of magnitude on modern architectures, see e.g. the Skylake section in <a href="http://www.agner.org/optimize/instruction_tables.pdf">http://www.agner.org/optimize/instruction_tables.pdf</a> (IMHO a must-read for anyone doing serious optimizations/measurements on the assembly level). And these numbers don't even include the effects of the caches, pipeline stalls, branch prediction, execution units/ports, etc. etc. which can easily add another 1 or 2 orders of magnitude.</div><div><br></div><div>So what can one do? It basically boils down to a choice:</div><div><br></div><div>   * Use a stable number like the instruction count (the "Instructions Read" (Ir) events), which has no real connection to the speed of a program.</div><div><br></div><div>   * Use a relatively volatile number like real time and/or cycles used, which is what your users will care about. If you put a non-trivial amount of work into your compiler, you can make these numbers a bit more stable (e.g. by making the code layout/alignment more stable), but you will still get quite different numbers if you switch to another CPU generation/manufacturer.</div><div><br></div><div>A bit tragic, but that's life in 2017... :-}</div></div></div></div>