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/) be available at build
18 The feature does not require modifying benchmark code. Counter collection is
19 handled at the boundaries where timer collection is also handled.
23 * Install `libpfm4-dev`, e.g. `apt-get install libpfm4-dev`.
24 * Enable the cmake flag BENCHMARK_ENABLE_LIBPFM.
26 To use, pass a comma-separated list of counter names through the
27 `--benchmark_perf_counters` flag. The names are decoded through libpfm - meaning,
28 they are platform specific, but some (e.g. `CYCLES` or `INSTRUCTIONS`) are
29 mapped by libpfm to platform-specifics - see libpfm
30 [documentation](http://perfmon2.sourceforge.net/docs.html) for more details.
32 The counter values are reported back through the [User Counters](../README.md#custom-counters)
33 mechanism, meaning, they are available in all the formats (e.g. JSON) supported