Master the fundamental concepts of profiling & measurement through this focused micro-challenge.
Valgrind's Callgrind simulates every instruction, so results are repeatable across machines even when hardware perf events are blocked in containers. KCachegrind turns Callgrind output into inclusive and exclusive cost views. It is slower than perf by 10x/50x, but invaluable when you need exact call counts on a laptop without perf permissions.
Inclusive cost counts time in a function plus everything it called. Exclusive cost is time spent inside the function body only. A high inclusive, low exclusive node means the callee is the real problem.
bashLoading…
callgrind.out files with callgrind_annotate --diffKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will profile a C program with Callgrind and interpret the annotated output. This exercise asks you to name the top three inclusive-cost functions and explain what each one does in your call graph.
Implement profiling with Valgrind Callgrind and KCachegrind visualization.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github