Bitcoin ABC  0.26.3
P2P Digital Currency
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 <util/time.h>
8 
9 static void BenchTimeDeprecated(benchmark::Bench &bench) {
10  bench.run([&] { (void)GetTime(); });
11 }
12 
13 static void BenchTimeMock(benchmark::Bench &bench) {
14  SetMockTime(111);
15  bench.run([&] { (void)GetTime<std::chrono::seconds>(); });
16  SetMockTime(0);
17 }
18 
19 static void BenchTimeMillis(benchmark::Bench &bench) {
20  bench.run([&] { (void)GetTime<std::chrono::milliseconds>(); });
21 }
22 
23 static void BenchTimeMillisSys(benchmark::Bench &bench) {
24  bench.run([&] { (void)GetTimeMillis(); });
25 }
26 
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:616
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1183
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:106
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:94
T GetTime()
Return system time (or mocked time, if set)
Definition: time.cpp:71
static void BenchTimeMock(benchmark::Bench &bench)
Definition: util_time.cpp:13
static void BenchTimeDeprecated(benchmark::Bench &bench)
Definition: util_time.cpp:9
static void BenchTimeMillis(benchmark::Bench &bench)
Definition: util_time.cpp:19
static void BenchTimeMillisSys(benchmark::Bench &bench)
Definition: util_time.cpp:23
BENCHMARK(BenchTimeDeprecated)