Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

util_time.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <bench/bench.h>
6 
7 #include <utiltime.h>
8 
10 {
11  while (state.KeepRunning()) {
12  (void)GetTime();
13  }
14 }
15 
16 static void BenchTimeMock(benchmark::State& state)
17 {
18  SetMockTime(111);
19  while (state.KeepRunning()) {
20  (void)GetTime<std::chrono::seconds>();
21  }
22  SetMockTime(0);
23 }
24 
25 static void BenchTimeMillis(benchmark::State& state)
26 {
27  while (state.KeepRunning()) {
28  (void)GetTime<std::chrono::milliseconds>();
29  }
30 }
31 
33 {
34  while (state.KeepRunning()) {
35  (void)GetTimeMillis();
36  }
37 }
38 
39 BENCHMARK(BenchTimeDeprecated/*, 100000000*/);
40 BENCHMARK(BenchTimeMillis/*, 6000000*/);
41 BENCHMARK(BenchTimeMillisSys/*, 6000000*/);
42 BENCHMARK(BenchTimeMock/*, 300000000*/);
static void BenchTimeDeprecated(benchmark::State &state)
Definition: util_time.cpp:9
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: utiltime.cpp:46
bool KeepRunning()
Definition: bench.cpp:39
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: utiltime.cpp:22
static void BenchTimeMillis(benchmark::State &state)
Definition: util_time.cpp:25
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: utiltime.cpp:56
static void BenchTimeMock(benchmark::State &state)
Definition: util_time.cpp:16
BENCHMARK(BenchTimeDeprecated)
static void BenchTimeMillisSys(benchmark::State &state)
Definition: util_time.cpp:32
Released under the MIT license