Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63856648
bm_common.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 22, 23:05
Size
1 KB
Mime Type
text/x-c
Expires
Fri, May 24, 23:05 (2 d)
Engine
blob
Format
Raw Data
Handle
17827668
Attached To
rSPECMICP SpecMiCP / ReactMiCP
bm_common.cpp
View Options
// this file is a micro-benchmark of the specmicp common libs
// It uses the google/benchmark framework
#include <benchmark/benchmark.h>
#include "utils/timer.hpp"
#include "utils/moving_average.hpp"
using namespace specmicp;
// Timer
// =====
static void BMTimer(benchmark::State& state) {
while (state.KeepRunning()) {
Timer timer;
timer.stop();
}
}
BENCHMARK(BMTimer);
static void BMTimer_restart(benchmark::State& state) {
while (state.KeepRunning()) {
Timer timer;
timer.start();
timer.stop();
}
}
BENCHMARK(BMTimer_restart);
static void BMTimer_elapsedtime(benchmark::State& state) {
while (state.KeepRunning()) {
Timer timer;
timer.stop();
scalar_t x;
benchmark::DoNotOptimize(x = timer.elapsed_time());
}
}
BENCHMARK(BMTimer_elapsedtime);
// Moving Average
// ==============
static void BMMovingAverage_init(benchmark::State& state) {
while (state.KeepRunning()) {
utils::ExponentialMovingAverage average(0.2, 1.0);
benchmark::DoNotOptimize(average);
}
}
BENCHMARK(BMMovingAverage_init);
static void BMMovingAverage_addpoint(benchmark::State& state) {
while (state.KeepRunning()) {
utils::ExponentialMovingAverage average(0.2, 1.0);
scalar_t x;
benchmark::DoNotOptimize(x = average.add_point(2.0));
}
}
BENCHMARK(BMMovingAverage_addpoint);
BENCHMARK_MAIN();
Event Timeline
Log In to Comment