<div dir="ltr"><div class="markdown-here-wrapper" style><p style="margin:1.2em 0px!important">Hi,</p>
<p style="margin:1.2em 0px!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><p>I tried to use some profiling tools like gcov and perf, but as far as
 I know they can only give me the frequency that each basic block is 
executed.</p></div></div></div></blockquote><p></p></div><p style="margin:1.2em 0px!important"></p>
<p style="margin:1.2em 0px!important">For perf, this really depends on what you’re sampling on. For your use case, it seems that sampling CPU cycles would give the data that you want.</p>
<p style="margin:1.2em 0px!important">If you run something like <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">perf record -e cycles -c 1000000 /path/to/program</code>, is that perf will collect one sample every 1’000’000 cpu cycles. If you have a 2GHz CPU, that would mean one sample every 0.5ms. So the time taken by a basic block is roughly the number of samples in that block times 0.5ms.</p>
<p style="margin:1.2em 0px!important">GCOV on the other hand will give you the number of times each basic block was executed, which does not tell much about the running time.</p>
<p style="margin:1.2em 0px!important">Cheers,<br>Jonas</p>
<p style="margin:1.2em 0px!important">PS: try to just run <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">perf stat /path/to/program</code> to see the relationships between cycles, runtime, and other metrics.</p>
<div title="MDH:SGksPGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj48Ymxv
Y2txdW90ZSBjbGFzcz0iZ21haWxfcXVvdG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