diff options
| author | Luke Dashjr <[email protected]> | 2016-01-15 05:17:15 +0000 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2016-01-15 05:17:15 +0000 |
| commit | 5bc4fb7b602c420be1c746442edad6b2d8e333ab (patch) | |
| tree | 32ce1458f7fafdf4f9a1dcb09091f1a6de416625 /src/bench/Examples.cpp | |
| parent | banlist (bugfix): allow CNode::SweepBanned() to run on interval (diff) | |
| parent | Merge pull request #7327 (diff) | |
| download | discoin-5bc4fb7b602c420be1c746442edad6b2d8e333ab.tar.xz discoin-5bc4fb7b602c420be1c746442edad6b2d8e333ab.zip | |
Merge branch 'master' into 20150703_banlist_updates
Diffstat (limited to 'src/bench/Examples.cpp')
| -rw-r--r-- | src/bench/Examples.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/bench/Examples.cpp b/src/bench/Examples.cpp new file mode 100644 index 000000000..b6b020a97 --- /dev/null +++ b/src/bench/Examples.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2015 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "bench.h" +#include "main.h" +#include "utiltime.h" + +// Sanity test: this should loop ten times, and +// min/max/average should be close to 100ms. +static void Sleep100ms(benchmark::State& state) +{ + while (state.KeepRunning()) { + MilliSleep(100); + } +} + +BENCHMARK(Sleep100ms); + +// Extremely fast-running benchmark: +#include <math.h> + +volatile double sum = 0.0; // volatile, global so not optimized away + +static void Trig(benchmark::State& state) +{ + double d = 0.01; + while (state.KeepRunning()) { + sum += sin(d); + d += 0.000001; + } +} + +BENCHMARK(Trig); |