Google Benchmark
A library to benchmark code snippets, similar to unit tests. - google/benchmark
Prefer Nanobench
More complete than folly benchmark. Simpler to setup.
Note
use -fno-omit-frame-pointer
to conserve callstack with optimized code
show perf
and `perf report -g ‘graph,0.5,caller’ to invert graph reported
define
- UNLIKELY -
__builtin_expected((bool)(x), 0)
Disabling CPU Frequency Scaling
Preventing Optimization
- DoNotOptimize(
) - ClobberMemory()
Some implementation
- escape - tell compiler that referenced object is modified (create/reserve test)
equivalent ofdoNotOptimizeAway
from folly.
- clobber - tell the compiler that whole memory is modified (push_back test).
BENCHMARK
BENCHMARK
loop can be customized.
Single Range
Dual Range
Install
work with Meson
subprojects/libgoogle_benchmark.wrap
Written on November 12, 2021, Last update on October 26, 2022
c++
lib
fastware
benchmarking