|
| 1 | +# CMetrics benchmarks |
| 2 | + |
| 3 | +Benchmarks are opt-in and are intended for before/after comparisons on the |
| 4 | +same machine. Build an optimized binary: |
| 5 | + |
| 6 | +```sh |
| 7 | +cmake -S . -B build-perf \ |
| 8 | + -DCMT_BENCHMARKS=ON \ |
| 9 | + -DCMT_INSTALL_TARGETS=OFF \ |
| 10 | + -DCMAKE_BUILD_TYPE=Release \ |
| 11 | + -DCMAKE_C_FLAGS_RELEASE='-O3 -DNDEBUG' |
| 12 | +cmake --build build-perf -j --target cmt-benchmark |
| 13 | +``` |
| 14 | + |
| 15 | +Run the standard repeated workloads and Linux hardware counters: |
| 16 | + |
| 17 | +```sh |
| 18 | +REPETITIONS=5 benchmarks/run-perf.sh \ |
| 19 | + ./build-perf/benchmarks/cmt-benchmark |
| 20 | +``` |
| 21 | + |
| 22 | +The executable also accepts individual workloads: |
| 23 | + |
| 24 | +```text |
| 25 | +cmt-benchmark lookup|update|prometheus|opentelemetry|opentelemetry-mixed CARDINALITY OPERATIONS |
| 26 | +``` |
| 27 | + |
| 28 | +The `opentelemetry` workload repeatedly encodes a labeled counter with the |
| 29 | +requested number of series. The `opentelemetry-mixed` workload creates that |
| 30 | +many counter, gauge, and histogram series to exercise scalar and aggregate |
| 31 | +protobuf data points in the same request. |
| 32 | + |
| 33 | +Compare medians from at least five alternating before/after runs. Keep CPU |
| 34 | +frequency policy, compiler, flags, machine load, and input parameters fixed. |
| 35 | +Use the reported in-process `elapsed_ns` for the operation itself and `perf |
| 36 | +stat` for whole-process hardware counters. Whole-process counters include |
| 37 | +series construction and teardown by design, exposing setup complexity as well |
| 38 | +as steady-state behavior. |
0 commit comments