benchmark/test/options_test.cc

38 lines
1005 B
C++
Raw Normal View History

2015-03-27 11:37:26 +08:00
#include "benchmark/benchmark_api.h"
#include "sleep.h"
2015-03-27 11:37:26 +08:00
void BM_basic(benchmark::State& state) {
while (state.KeepRunning()) {
}
}
void BM_basic_slow(benchmark::State& state) {
while (state.KeepRunning()) {
benchmark::SleepForMilliseconds(state.range_x());
}
}
2015-03-27 11:37:26 +08:00
BENCHMARK(BM_basic);
BENCHMARK(BM_basic)->Arg(42);
BENCHMARK(BM_basic_slow)->Arg(10)->Unit(benchmark::kNanosecond);
BENCHMARK(BM_basic_slow)->Arg(100)->Unit(benchmark::kMicrosecond);
BENCHMARK(BM_basic_slow)->Arg(1000)->Unit(benchmark::kMillisecond);
2015-03-27 11:37:26 +08:00
BENCHMARK(BM_basic)->Range(1, 8);
BENCHMARK(BM_basic)->DenseRange(10, 15);
BENCHMARK(BM_basic)->ArgPair(42, 42);
BENCHMARK(BM_basic)->RangePair(64, 512, 64, 512);
BENCHMARK(BM_basic)->MinTime(0.7);
BENCHMARK(BM_basic)->UseRealTime();
BENCHMARK(BM_basic)->ThreadRange(2, 4);
BENCHMARK(BM_basic)->ThreadPerCpu();
void CustomArgs(benchmark::internal::Benchmark* b) {
for (int i = 0; i < 10; ++i) {
b->Arg(i);
}
}
BENCHMARK(BM_basic)->Apply(CustomArgs);
2015-03-27 11:37:26 +08:00
BENCHMARK_MAIN()