You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
782 B
35 lines
782 B
9 years ago
|
// 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"
|
||
|
|
||
9 years ago
|
// Sanity test: this should loop ten times, and
|
||
|
// min/max/average should be close to 100ms.
|
||
9 years ago
|
static void Sleep100ms(benchmark::State& state)
|
||
|
{
|
||
|
while (state.KeepRunning()) {
|
||
|
MilliSleep(100);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
BENCHMARK(Sleep100ms);
|
||
9 years ago
|
|
||
|
// 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);
|