• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_BENCHMARKING_BENCHMARKING_H_
6 #define FLUTTER_BENCHMARKING_BENCHMARKING_H_
7 
8 #include "benchmark/benchmark_api.h"
9 
10 namespace benchmarking {
11 
12 class ScopedPauseTiming {
13  public:
14   ScopedPauseTiming(::benchmark::State& state, bool enabled = true)
state_(state)15       : state_(state), enabled_(enabled) {
16     if (enabled_) {
17       state_.PauseTiming();
18     }
19   }
~ScopedPauseTiming()20   ~ScopedPauseTiming() {
21     if (enabled_) {
22       state_.ResumeTiming();
23     }
24   }
25 
26  private:
27   ::benchmark::State& state_;
28   const bool enabled_;
29 };
30 
31 }  // namespace benchmarking
32 
33 #endif  // FLUTTER_BENCHMARKING_BENCHMARKING_H_
34