1 <a name="perf-counters" />
3 # User-Requested Performance Counters
5 When running benchmarks, the user may choose to request collection of
6 performance counters. This may be useful in investigation scenarios - narrowing
7 down the cause of a regression; or verifying that the underlying cause of a
8 performance improvement matches expectations.
10 This feature is available if:
12 * The benchmark is run on an architecture featuring a Performance Monitoring
14 * The benchmark is compiled with support for collecting counters. Currently,
15 this requires [libpfm](http://perfmon2.sourceforge.net/), which is built as a
18 The feature does not require modifying benchmark code. Counter collection is
19 handled at the boundaries where timer collection is also handled.
22 * If using a Bazel build, add `--define pfm=1` to your build flags
24 * Install `libpfm4-dev`, e.g. `apt-get install libpfm4-dev`.
25 * Enable the CMake flag `BENCHMARK_ENABLE_LIBPFM` in `CMakeLists.txt`.
27 To use, pass a comma-separated list of counter names through the
28 `--benchmark_perf_counters` flag. The names are decoded through libpfm - meaning,
29 they are platform specific, but some (e.g. `CYCLES` or `INSTRUCTIONS`) are
30 mapped by libpfm to platform-specifics - see libpfm
31 [documentation](http://perfmon2.sourceforge.net/docs.html) for more details.
33 The counter values are reported back through the [User Counters](../README.md#custom-counters)
34 mechanism, meaning, they are available in all the formats (e.g. JSON) supported