https://github.com/rnburn/touchstone
c++ library for benchmarking
https://github.com/rnburn/touchstone
Last synced: 2 months ago
JSON representation
c++ library for benchmarking
- Host: GitHub
- URL: https://github.com/rnburn/touchstone
- Owner: rnburn
- License: apache-2.0
- Created: 2014-09-10T20:07:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-09T19:39:07.000Z (about 10 years ago)
- Last Synced: 2025-01-20T02:49:21.343Z (4 months ago)
- Language: C++
- Size: 219 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
#Touchstone
A small C++ benchmarking library that lets you create benchmarks in a style similar
to the [Catch](https://github.com/philsquared/Catch/) testing framework.###Quickstart
Suppose you want to compare the STL functions ```std::sort``` and ```std::stable_sort```.
Write
```C++
BENCHMARK_SET(
"sort"
, NumEpochs{10}
, NumTrials{100}
, LinearRange{10, 100}
)
{
int n = touchstone::n();
std::vector v(n);
std::generate_n(v.begin(), n, touchstone::random_number_generator());
BENCHMARK("unstable") {
std::sort(v.begin(), v.end());
}
BENCHMARK("stable") {
// v will be unsorted when this benchmark section is run
// because benchmark sections are run excusively
std::stable_sort(v.begin(), v.end());
}
touchstone::do_not_optimize_away(v[0]);
}
```
Touchstone calls the benchmarking function across the range of values ```n=10``` to ```n=100```.
For each value of ```n```, the function is called ```NumEpochs * NumTrials``` times. Every epoch
is estimated ```NumTrials``` times, each time using a random number generator seeded with
the same value. As with [Catch](https://github.com/philsquared/Catch/), only a single ```BENCHMARK```
section is executed every time the function is run, eliminating the need for fixtures.Results are written to a tab-separated file, which can be easily plotted.
