Bitcoin ABC  0.24.10
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 
BenchTimeMock
static void BenchTimeMock(benchmark::Bench &bench)
Definition: util_time.cpp:13
BENCHMARK
BENCHMARK(BenchTimeDeprecated)
GetTime
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
Definition: time.cpp:27
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:583
BenchTimeMillisSys
static void BenchTimeMillisSys(benchmark::Bench &bench)
Definition: util_time.cpp:23
SetMockTime
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: time.cpp:50
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1134
time.h
bench.h
BenchTimeMillis
static void BenchTimeMillis(benchmark::Bench &bench)
Definition: util_time.cpp:19
BenchTimeDeprecated
static void BenchTimeDeprecated(benchmark::Bench &bench)
Definition: util_time.cpp:9
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:59