From d8deba8c36a42481b1c1e73009d7c9cc2cb25f70 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Mon, 11 Jul 2022 10:58:29 +0200 Subject: [PATCH] bench: add LogPrintfCategory and LogPrintLevel benchmarks for these new macros that our logging is planned to migrate to. At some point it may be feasible to drop some of the previous logging benchmarks. --- src/bench/logging.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/bench/logging.cpp b/src/bench/logging.cpp index a7162d09acbf0..f6e5bc54e87f8 100644 --- a/src/bench/logging.cpp +++ b/src/bench/logging.cpp @@ -20,6 +20,18 @@ static void Logging(benchmark::Bench& bench, const std::vector& ext bench.run([&] { log(); }); } +static void LogPrintLevelWithThreadNames(benchmark::Bench& bench) +{ + Logging(bench, {"-logthreadnames=1", "-debug=net"}, [] { + LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); }); +} + +static void LogPrintLevelWithoutThreadNames(benchmark::Bench& bench) +{ + Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { + LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); }); +} + static void LogPrintWithCategory(benchmark::Bench& bench) { Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); }); @@ -30,6 +42,20 @@ static void LogPrintWithoutCategory(benchmark::Bench& bench) Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); }); } +static void LogPrintfCategoryWithThreadNames(benchmark::Bench& bench) +{ + Logging(bench, {"-logthreadnames=1", "-debug=net"}, [] { + LogPrintfCategory(BCLog::NET, "%s\n", "test"); + }); +} + +static void LogPrintfCategoryWithoutThreadNames(benchmark::Bench& bench) +{ + Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { + LogPrintfCategory(BCLog::NET, "%s\n", "test"); + }); +} + static void LogPrintfWithThreadNames(benchmark::Bench& bench) { Logging(bench, {"-logthreadnames=1"}, [] { LogPrintf("%s\n", "test"); }); @@ -48,8 +74,12 @@ static void LogWithoutWriteToFile(benchmark::Bench& bench) }); } +BENCHMARK(LogPrintLevelWithThreadNames, benchmark::PriorityLevel::HIGH); +BENCHMARK(LogPrintLevelWithoutThreadNames, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintWithCategory, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintWithoutCategory, benchmark::PriorityLevel::HIGH); +BENCHMARK(LogPrintfCategoryWithThreadNames, benchmark::PriorityLevel::HIGH); +BENCHMARK(LogPrintfCategoryWithoutThreadNames, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintfWithThreadNames, benchmark::PriorityLevel::HIGH); BENCHMARK(LogPrintfWithoutThreadNames, benchmark::PriorityLevel::HIGH); BENCHMARK(LogWithoutWriteToFile, benchmark::PriorityLevel::HIGH);