LevelDB project 1 10225501460 林子骥 10211900416 郭夏辉
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.5 KiB

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