Austin Schuh | cbc1740 | 2019-01-21 21:00:30 -0800 | [diff] [blame^] | 1 | #include "benchmark/benchmark.h" |
2 | |||||
3 | void BM_StringCreation(benchmark::State& state) { | ||||
4 | while (state.KeepRunning()) | ||||
5 | std::string empty_string; | ||||
6 | } | ||||
7 | |||||
8 | BENCHMARK(BM_StringCreation); | ||||
9 | |||||
10 | void BM_StringCopy(benchmark::State& state) { | ||||
11 | std::string x = "hello"; | ||||
12 | while (state.KeepRunning()) | ||||
13 | std::string copy(x); | ||||
14 | } | ||||
15 | |||||
16 | BENCHMARK(BM_StringCopy); | ||||
17 | |||||
18 | BENCHMARK_MAIN(); |