Profiling & performance analysis
Hare does not provide any Hare-specific profiling tools, but it is compatible with most standard performance analysis tools.
Note
Are you familiar with profiling tools for your operating system of choice, but it’s not covered here? If so, please send us a patch improving this page.
perf(1)
perf(1) is a high-performance, Linux-specific analysis tool.
To profile the example program above, run perf record -g <command>
to
record a profile at ./perf.data
. Terminate the program with Ctrl+C after
collecting enough samples, and view the report with perf report
.
perf can also analyze various events, monitor CPU performance registers to characterize behavior like cache misses and branch prediction, and much more. See also: perf wiki
Visualizing reports with Firefox
The most accessible and readily available tool for analyzing perf reports is Firefox. Here is a quick recipe to view this report in Firefox:
$ perf script record gecko <command>
# ... press ctrl+c eventually...
$ perf script report gecko <command>
This will open the profile report in your default web browser. You can also share this URL to share profiles with your collaborators – you can see a sample report here.
callgrind
callgrind is an generic intrusive profiler that’s part of the Valgrind
suite. To capture a profile of the sample program above, run valgrind
--tool=callgrind -v --dump-every-bb=10000000 <command>
and press Ctrl+C
after gathering enough samples. The profile is written to the current working
directory in callgrind.out.*
files.
Callgrind supports Linux and FreeBSD.
Visualizing reports with Kcachegrind
Kcachegrind is a graphical tool for exploring a profile captured with
callgrind. Simply run kcachegrind
from the same directory as the profile
was captured to browse the results.
Memory analysis
There are limited tools currently available for analyzing the memory usage of Hare programs, though this will be improved in the future.
It is possible to analyze Hare programs with Valgrind provied that they are
linked to libc, which is done with hare build -lc ...
.