Search code examples
valgrindcachegrind

Limiting data collection of Cachegrind, in Valgrind


It is well known that, the callgrind analysis tool of the valgrind suit, provides the possibility to start and stop the colection of data via command line instruction callgrind_control -i on or callgrind_control -i off. For instance, the following code will collect data only after the hour.

(sleep 3600; callgrind_control -i on) &
valgrind --tool=callgrind --instr-atstart=no ./myprog

Is there a similar option for the cachegrind tool? if so, how can I use it (I do not find anything in the documentation)? If no, how can I start collecting data after a certain amount of time with cachegrind?


Solution

  • As far as I know, there is no such function for Cachegrind.

    However, Callgrind is an extension of Cachegrind, which means that you can use Cachegrind features on Callgrind.

    For example:

    valgrind --tool=callgrind --cache-sim=yes --branch-sim=yes ./myprog
    

    Will measure your programs cache and branch performance as if you where using Cachegrind.