[LLVMdev] Measure execution time of each basic block

Jonas Wagner jonas.wagner at epfl.ch
Fri Sep 19 15:37:08 PDT 2014


Hi,

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.
>
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.

If you run something like perf record -e cycles -c 1000000 /path/to/program,
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.

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.

Cheers,
Jonas

PS: try to just run perf stat /path/to/program to see the relationships
between cycles, runtime, and other metrics.
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140920/6f044a2f/attachment.html>


More information about the llvm-dev mailing list