Output Format

The Iai-Callgrind output can be customized with command-line arguments. But, the fine-grained terminal output format is adjusted in the benchmark itself. For example truncating the description, showing a grid, .... Please read the docs for further details.

However, I want to point out the possibility to show the cache misses in the Iai-Callgrind output in the following section.

Showing cache misses

A default Iai-Callgrind benchmark run displays the following metrics:

test_lib_bench_readme_example_fibonacci::bench_fibonacci_group::bench_fibonacci short:10
  Instructions:                        1734|1734                 (No change)
  L1 Hits:                             2359|2359                 (No change)
  L2 Hits:                                0|0                    (No change)
  RAM Hits:                               3|3                    (No change)
  Total read+write:                    2362|2362                 (No change)
  Estimated Cycles:                    2464|2464                 (No change)

Iai-Callgrind result: Ok. 1 without regressions; 0 regressed; 1 benchmarks finished in 0.49333s

The cache and ram hits, Total read+write and Estimated Cycles are actually not part of the original collected callgrind metrics but calculated from them. If you want to see the cache misses nonetheless, you can achieve this by specifying the output format for example at top-level for all benchmarks in the same file in the main! macro:

extern crate iai_callgrind;
use iai_callgrind::{library_benchmark, library_benchmark_group};
use iai_callgrind::{main, LibraryBenchmarkConfig, OutputFormat, CallgrindMetrics, Callgrind};

#[library_benchmark] fn bench() {}
library_benchmark_group!(name = my_group; benchmarks = bench);
fn main() {
main!(
    config = LibraryBenchmarkConfig::default()
        .tool(Callgrind::default()
            .format([CallgrindMetrics::All])
        );
    library_benchmark_groups = my_group
);
}

The Iai-Callgrind output will then show all cache metrics:

test_lib_bench_readme_example_fibonacci::my_group::bench_fibonacci short:10
  Instructions:                        1734|1734                 (No change)
  Dr:                                   270|270                  (No change)
  Dw:                                   358|358                  (No change)
  I1mr:                                   3|3                    (No change)
  D1mr:                                   0|0                    (No change)
  D1mw:                                   0|0                    (No change)
  ILmr:                                   3|3                    (No change)
  DLmr:                                   0|0                    (No change)
  DLmw:                                   0|0                    (No change)
  L1 Hits:                             2359|2359                 (No change)
  L2 Hits:                                0|0                    (No change)
  RAM Hits:                               3|3                    (No change)
  Total read+write:                    2362|2362                 (No change)
  Estimated Cycles:                    2464|2464                 (No change)

Iai-Callgrind result: Ok. 1 without regressions; 0 regressed; 1 benchmarks finished in 0.49301s

The callgrind output format can be fully customized showing only the metrics you're interested in and in any order. The docs of Callgrind::format and CallgrindMetrics show all the possibilities for Callgrind. The output format of the other valgrind tools can be customized in the same way. Just have a look at the docs for the respective format (Dhat::format, DhatMetric, Cachegrind::format, CachegrindMetric, ...)