Skip to content

Commit

Permalink
More benchmarking code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Nilsson committed Jan 14, 2020
1 parent ac0fb23 commit 1e62adb
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion performance_test/PerformanceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,45 @@ static void BM_RandomSeverityLevel(benchmark::State &state) {
std::mt19937 Generator(Device());
std::uniform_int_distribution<> Distribution(0, 7);
for (auto _ : state) {
Logger.log(Log::Severity(Distribution(Generator)), "Some format example");
Logger.log(Log::Severity(Distribution(Generator)), "Some test string.");
}
state.SetItemsProcessed(state.iterations());
}
BENCHMARK(BM_RandomSeverityLevel);

//#include "spdlog/spdlog.h"
//#include "spdlog/sinks/null_sink.h"
//#include "spdlog/async.h"
//
//static void BM_SpdLogWithFmtAndSeverityLvl(benchmark::State &state) {
// Log::LoggingBase Logger;
// auto null_sink = std::make_shared<spdlog::sinks::null_sink_mt>();
// auto tp = std::make_shared<spdlog::details::thread_pool>(4096, 1);
// auto logger = std::make_shared<spdlog::async_logger>("async_logger", std::move(null_sink), std::move(tp), spdlog::async_overflow_policy::overrun_oldest);
// std::random_device Device;
// std::mt19937 Generator(Device());
// std::uniform_int_distribution<> Distribution(0, 6);
// logger->set_level(spdlog::level::level_enum(3));
// for (auto _ : state) {
// logger->log(spdlog::level::level_enum(Distribution(Generator)), "Hello - {} - {} - {}", 42, 3.14, "test");
// }
// state.SetItemsProcessed(state.iterations());
//}
//BENCHMARK(BM_SpdLogWithFmtAndSeverityLvl);

static void BM_GraylogWithFmtAndSeverityLvl(benchmark::State &state) {
Log::LoggingBase Logger;
Logger.setMinSeverity(Log::Severity(3));
auto Handler = std::make_shared<DummyLogHandler>();
Logger.addLogHandler(std::dynamic_pointer_cast<Log::BaseLogHandler>(Handler));
std::random_device Device;
std::mt19937 Generator(Device());
std::uniform_int_distribution<> Distribution(0, 6);
for (auto _ : state) {
Logger.fmt_log(Log::Severity(Distribution(Generator)), "Hello - {} - {} - {}", 42, 3.14, "test");
}
state.SetItemsProcessed(state.iterations());
}
BENCHMARK(BM_GraylogWithFmtAndSeverityLvl);

BENCHMARK_MAIN();

0 comments on commit 1e62adb

Please sign in to comment.