Introduce benchmark test for rotate_cpx_vector
This commit introduces google benchmark library and one benchmark for rotate_cpx_vector. Also extracted common tools used in testcases for generation and allocation of byte aligned vectors in phy_test_tools.hpp
This commit is contained in:
committed by
Robert Schmidt
parent
46a1d2a621
commit
0883904891
@@ -107,3 +107,65 @@ that directory directly, which you might also use to compare to the
|
||||
slight complication is due to using shell scripts. An easier way is to
|
||||
directly declare the executable in `add_test()`, and `ctest` will locate and
|
||||
run the executable properly.
|
||||
|
||||
# Benchmarking
|
||||
|
||||
Google benchmark can be used to profile and benchmark small pieces of code. See
|
||||
`benchmark_rotate_vector` for reference implementation. To start benchmarking code,
|
||||
write a benchmark first and compare your implementation against baseline result.
|
||||
To ensure your results are reproducible see this [guide](https://github.com/google/benchmark/blob/main/docs/reducing_variance.md)
|
||||
|
||||
Example output follows:
|
||||
|
||||
```bash
|
||||
2024-08-26T11:55:49+02:00
|
||||
Running ./openair1/PHY/TOOLS/tests/benchmark_rotate_vector
|
||||
Run on (8 X 4700 MHz CPU s)
|
||||
CPU Caches:
|
||||
L1 Data 48 KiB (x4)
|
||||
L1 Instruction 32 KiB (x4)
|
||||
L2 Unified 1280 KiB (x4)
|
||||
L3 Unified 12288 KiB (x1)
|
||||
Load Average: 0.51, 0.31, 0.29
|
||||
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
|
||||
---------------------------------------------------------------------
|
||||
Benchmark Time CPU Iterations
|
||||
---------------------------------------------------------------------
|
||||
BM_rotate_cpx_vector/100 43.1 ns 43.1 ns 16683136
|
||||
BM_rotate_cpx_vector/256 70.1 ns 70.0 ns 9647446
|
||||
BM_rotate_cpx_vector/1024 277 ns 277 ns 2378273
|
||||
BM_rotate_cpx_vector/4096 1070 ns 1070 ns 654792
|
||||
BM_rotate_cpx_vector/16384 4220 ns 4220 ns 169070
|
||||
BM_rotate_cpx_vector/20000 5288 ns 5289 ns 136190
|
||||
```
|
||||
|
||||
## Comparing results
|
||||
|
||||
Benchmark results can be output to json by using command line arguments, example below
|
||||
|
||||
```bash
|
||||
./benchmark_rotate_vector --benchmark_out=file.json --benchmark_repetitions=10
|
||||
```
|
||||
|
||||
These results can be compared by a tool provided with google benchmark
|
||||
|
||||
```bash
|
||||
./compare.py benchmarks ../../file.json ../../file1.json
|
||||
```
|
||||
|
||||
Example output:
|
||||
```
|
||||
Comparing ../../file.json to ../../file1.json
|
||||
Benchmark Time CPU Time Old Time New CPU Old CPU New
|
||||
--------------------------------------------------------------------------------------------------------------------------------
|
||||
BM_rotate_cpx_vector/100 +0.3383 +0.3384 43 58 43 58
|
||||
BM_rotate_cpx_vector/100 +0.2334 +0.2335 42 52 42 52
|
||||
BM_rotate_cpx_vector/100 +0.1685 +0.1683 42 49 42 49
|
||||
BM_rotate_cpx_vector/100 +0.1890 +0.1889 42 50 42 50
|
||||
BM_rotate_cpx_vector/100 +0.0456 +0.0457 42 44 42 44
|
||||
BM_rotate_cpx_vector/100 +0.0163 +0.0162 42 42 42 42
|
||||
BM_rotate_cpx_vector/100 +0.0005 +0.0004 43 43 43 43
|
||||
BM_rotate_cpx_vector/100 +0.0134 +0.0129 43 43 43 43
|
||||
BM_rotate_cpx_vector/100 +0.0162 +0.0162 42 42 42 42
|
||||
BM_rotate_cpx_vector/100 +0.0003 +0.0003 42 42 42 42
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user