2022-04-21 00:31:26 +02:00
|
|
|
# Building and Running
|
|
|
|
|
2022-04-20 20:54:36 +02:00
|
|
|
Benchmarks are implemented using [Google Benchmark](https://github.com/google/benchmark).
|
|
|
|
|
|
|
|
To build the benchmarks in this directory you need to set the benchmark
|
|
|
|
option while configuring the build with meson:
|
|
|
|
|
|
|
|
```
|
2022-06-30 21:50:18 +02:00
|
|
|
meson build -Dbenchmark=enabled --buildtype=release
|
|
|
|
```
|
|
|
|
or:
|
|
|
|
```
|
|
|
|
meson build -Dbenchmark=enabled --buildtype=debugoptimized
|
2022-04-20 20:54:36 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2022-06-30 21:50:18 +02:00
|
|
|
Then build a specific benchmark binaries with ninja:
|
2022-04-20 20:54:36 +02:00
|
|
|
```
|
|
|
|
ninja -Cbuild perf/benchmark-set
|
|
|
|
```
|
2022-06-30 21:50:18 +02:00
|
|
|
or just build the whole project:
|
|
|
|
```
|
|
|
|
ninja -Cbuild
|
|
|
|
```
|
2022-04-20 20:54:36 +02:00
|
|
|
|
|
|
|
Finally, to run one of the benchmarks:
|
|
|
|
|
|
|
|
```
|
|
|
|
./build/perf/benchmark-set
|
|
|
|
```
|
|
|
|
|
|
|
|
It's possible to filter the benchmarks being run and customize the output
|
|
|
|
via flags to the benchmark binary. See the
|
|
|
|
[Google Benchmark User Guide](https://github.com/google/benchmark/blob/main/docs/user_guide.md#user-guide) for more details.
|
2022-04-21 00:31:26 +02:00
|
|
|
|
|
|
|
# Profiling
|
|
|
|
|
|
|
|
Configure the build to include debug information for profiling:
|
|
|
|
|
|
|
|
```
|
|
|
|
CXXFLAGS="-fno-omit-frame-pointer" meson --reconfigure build -Dbenchmark=enabled --buildtype=debug
|
2022-04-21 00:32:54 +02:00
|
|
|
ninja -Cbuild
|
2022-04-21 00:31:26 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Then run the benchmark with perf:
|
|
|
|
|
|
|
|
```
|
2022-06-30 21:50:18 +02:00
|
|
|
perf record -g build/perf/benchmark-subset --benchmark_filter="BM_subset_codepoints/subset_notocjk/100000" --benchmark_repetitions=5
|
2022-04-21 00:31:26 +02:00
|
|
|
```
|
|
|
|
You probably want to filter to a specific benchmark of interest and set the number of repititions high enough to get a good sampling of profile data.
|
|
|
|
|
|
|
|
Finally view the profile with:
|
|
|
|
|
2022-06-30 21:50:18 +02:00
|
|
|
perf report
|