File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ ../google_benchmark_cmake/pause_timing_bench.hpp
Original file line number Diff line number Diff line change 5
5
#include " fibonacci_bench.hpp"
6
6
#include " fixture_bench.hpp"
7
7
#include " multithread_bench.hpp"
8
+ #include " pause_timing_bench.hpp"
8
9
#include " sleep_bench.hpp"
9
10
#include " template_bench.hpp"
10
11
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include < benchmark/benchmark.h>
4
+
5
+ #include < chrono>
6
+ #include < thread>
7
+
8
+ #include " helper.hpp"
9
+
10
+ NOINLINE static uint64_t actual_work () {
11
+ std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
12
+ return 42 ;
13
+ }
14
+
15
+ static void BM_large_setup_teardown (benchmark::State& state) {
16
+ for (auto _ : state) {
17
+ state.PauseTiming ();
18
+ benchmark::DoNotOptimize (expensive_operation ());
19
+ state.ResumeTiming ();
20
+
21
+ benchmark::DoNotOptimize (actual_work ());
22
+
23
+ state.PauseTiming ();
24
+ benchmark::DoNotOptimize (expensive_operation ());
25
+ state.ResumeTiming ();
26
+ }
27
+ }
28
+ // IMPORTANT: Use fixed iterations, otherwise we'll run for 10+ minutes
29
+ BENCHMARK (BM_large_setup_teardown)->Iterations(100 );
30
+
31
+ static void BM_large_setup (benchmark::State& state) {
32
+ for (auto _ : state) {
33
+ state.PauseTiming ();
34
+ benchmark::DoNotOptimize (expensive_operation ());
35
+ state.ResumeTiming ();
36
+
37
+ benchmark::DoNotOptimize (actual_work ());
38
+ }
39
+ }
40
+ BENCHMARK (BM_large_setup);
You can’t perform that action at this time.
0 commit comments