Files
cpp-project-template/third_party/benchmark/docs/perf_counters.md
tqcq ea9d7b5f8c
All checks were successful
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Successful in 1m7s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Successful in 1m15s
sm-rpc / build (Debug, host.gcc) (push) Successful in 1m4s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Successful in 1m16s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Successful in 1m34s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Successful in 1m33s
sm-rpc / build (Release, host.gcc) (push) Successful in 1m23s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Successful in 1m30s
feat(third_party): add oatpp,googltest,benchmark
2025-08-19 17:19:37 +08:00

1.5 KiB

User-Requested Performance Counters

When running benchmarks, the user may choose to request collection of performance counters. This may be useful in investigation scenarios - narrowing down the cause of a regression; or verifying that the underlying cause of a performance improvement matches expectations.

This feature is available if:

The feature does not require modifying benchmark code. Counter collection is handled at the boundaries where timer collection is also handled.

To opt-in:

  • If using a Bazel build, add --define pfm=1 to your build flags
  • If using CMake:
    • Install libpfm4-dev, e.g. apt-get install libpfm4-dev.
    • Enable the CMake flag BENCHMARK_ENABLE_LIBPFM in CMakeLists.txt.

To use, pass a comma-separated list of counter names through the --benchmark_perf_counters flag. The names are decoded through libpfm - meaning, they are platform specific, but some (e.g. CYCLES or INSTRUCTIONS) are mapped by libpfm to platform-specifics - see libpfm documentation for more details.

The counter values are reported back through the User Counters mechanism, meaning, they are available in all the formats (e.g. JSON) supported by User Counters.