Page MenuHomec4science

bm_logging.cpp
No OneTemporary

File Metadata

Created
Mon, Oct 7, 08:19

bm_logging.cpp

// this file is a micro-benchmark of the logging capacity
//
// right now, this is mainly a test of the data_container.
// It uses the google/benchmark framework
#include <benchmark/benchmark.h>
#include "../src/utils/log.hpp"
#include <iostream>
#include <fstream>
using namespace specmicp;
static void InitLogger(benchmark::State& state) {
while (state.KeepRunning()) {
std::ofstream stream("/dev/null");
specmicp::init_logger(&stream, specmicp::logger::Info);
}
}
BENCHMARK(InitLogger);
static void WarningMessage(benchmark::State& state) {
while (state.KeepRunning()) {
std::ofstream stream("/dev/null");
specmicp::init_logger(&stream, specmicp::logger::Info);
WARNING << "warning message";
}
}
// Register the function as a benchmark
BENCHMARK(WarningMessage);
static void ErrorMessage(benchmark::State& state) {
while (state.KeepRunning()) {
std::ofstream stream("/dev/null");
specmicp::init_logger(&stream, specmicp::logger::Info);
WARNING << "error message";
}
}
// Register the function as a benchmark
BENCHMARK(ErrorMessage);
BENCHMARK_MAIN();

Event Timeline