File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-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_drop (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
+ BENCHMARK (BM_large_drop);
29
+
30
+ static void BM_large_setup (benchmark::State& state) {
31
+ for (auto _ : state) {
32
+ state.PauseTiming ();
33
+ benchmark::DoNotOptimize (expensive_operation ());
34
+ state.ResumeTiming ();
35
+
36
+ benchmark::DoNotOptimize (actual_work ());
37
+ }
38
+ }
39
+ BENCHMARK (BM_large_setup);
You can’t perform that action at this time.
0 commit comments