Skip to content

Commit d8deba8

Browse files
committed
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.
1 parent 102b203 commit d8deba8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/bench/logging.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ static void Logging(benchmark::Bench& bench, const std::vector<const char*>& ext
2020
bench.run([&] { log(); });
2121
}
2222

23+
static void LogPrintLevelWithThreadNames(benchmark::Bench& bench)
24+
{
25+
Logging(bench, {"-logthreadnames=1", "-debug=net"}, [] {
26+
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); });
27+
}
28+
29+
static void LogPrintLevelWithoutThreadNames(benchmark::Bench& bench)
30+
{
31+
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] {
32+
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); });
33+
}
34+
2335
static void LogPrintWithCategory(benchmark::Bench& bench)
2436
{
2537
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
@@ -30,6 +42,20 @@ static void LogPrintWithoutCategory(benchmark::Bench& bench)
3042
Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
3143
}
3244

45+
static void LogPrintfCategoryWithThreadNames(benchmark::Bench& bench)
46+
{
47+
Logging(bench, {"-logthreadnames=1", "-debug=net"}, [] {
48+
LogPrintfCategory(BCLog::NET, "%s\n", "test");
49+
});
50+
}
51+
52+
static void LogPrintfCategoryWithoutThreadNames(benchmark::Bench& bench)
53+
{
54+
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] {
55+
LogPrintfCategory(BCLog::NET, "%s\n", "test");
56+
});
57+
}
58+
3359
static void LogPrintfWithThreadNames(benchmark::Bench& bench)
3460
{
3561
Logging(bench, {"-logthreadnames=1"}, [] { LogPrintf("%s\n", "test"); });
@@ -48,8 +74,12 @@ static void LogWithoutWriteToFile(benchmark::Bench& bench)
4874
});
4975
}
5076

77+
BENCHMARK(LogPrintLevelWithThreadNames, benchmark::PriorityLevel::HIGH);
78+
BENCHMARK(LogPrintLevelWithoutThreadNames, benchmark::PriorityLevel::HIGH);
5179
BENCHMARK(LogPrintWithCategory, benchmark::PriorityLevel::HIGH);
5280
BENCHMARK(LogPrintWithoutCategory, benchmark::PriorityLevel::HIGH);
81+
BENCHMARK(LogPrintfCategoryWithThreadNames, benchmark::PriorityLevel::HIGH);
82+
BENCHMARK(LogPrintfCategoryWithoutThreadNames, benchmark::PriorityLevel::HIGH);
5383
BENCHMARK(LogPrintfWithThreadNames, benchmark::PriorityLevel::HIGH);
5484
BENCHMARK(LogPrintfWithoutThreadNames, benchmark::PriorityLevel::HIGH);
5585
BENCHMARK(LogWithoutWriteToFile, benchmark::PriorityLevel::HIGH);

0 commit comments

Comments
 (0)