PIVX Core
5.6.99
P2P Digital Currency
src
bench
Examples.cpp
Go to the documentation of this file.
1
// Copyright (c) 2015 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.h
"
6
#include "
utiltime.h
"
7
8
// Sanity test: this should loop ten times, and
9
// min/max/average should be close to 100ms.
10
static
void
Sleep100ms(
benchmark::State
& state)
11
{
12
while
(state.
KeepRunning
()) {
13
MilliSleep
(100);
14
}
15
}
16
17
BENCHMARK
(Sleep100ms, 10);
18
19
// Extremely fast-running benchmark:
20
#include <math.h>
21
22
volatile
double
sum
= 0.0;
// volatile, global so not optimized away
23
24
static
void
Trig(
benchmark::State
& state)
25
{
26
double
d = 0.01;
27
while
(state.
KeepRunning
()) {
28
sum
+= sin(d);
29
d += 0.000001;
30
}
31
}
32
33
BENCHMARK
(Trig, 12 * 1000 * 1000);
sum
volatile double sum
Definition:
Examples.cpp:22
BENCHMARK
BENCHMARK(Sleep100ms, 10)
benchmark::State
Definition:
bench.h:54
benchmark::State::KeepRunning
bool KeepRunning()
Definition:
bench.h:69
bench.h
MilliSleep
void MilliSleep(int64_t n)
Definition:
utiltime.cpp:82
utiltime.h
Generated on Wed Apr 2 2025 00:40:26 for PIVX Core by
1.9.1