Line data Source code
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 "main.h"
7 : #include "utiltime.h"
8 :
9 : // Sanity test: this should loop ten times, and
10 : // min/max/average should be close to 100ms.
11 0 : static void Sleep100ms(benchmark::State& state)
12 : {
13 0 : while (state.KeepRunning()) {
14 0 : MilliSleep(100);
15 : }
16 0 : }
17 :
18 0 : BENCHMARK(Sleep100ms);
19 :
20 : // Extremely fast-running benchmark:
21 : #include <math.h>
22 :
23 : volatile double sum = 0.0; // volatile, global so not optimized away
24 :
25 0 : static void Trig(benchmark::State& state)
26 : {
27 0 : double d = 0.01;
28 0 : while (state.KeepRunning()) {
29 0 : sum += sin(d);
30 0 : d += 0.000001;
31 : }
32 0 : }
33 :
34 0 : BENCHMARK(Trig);
|