Skip to content

Commit 7026c61

Browse files
MarcoFalkejanus
MarcoFalke
authored andcommittedJul 7, 2022
bench: Add logging benchmark
1 parent 22fa4f2 commit 7026c61

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
 

‎src/Makefile.bench.include

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ bench_bench_BGL_SOURCES = \
3030
bench/ccoins_caching.cpp \
3131
bench/gcs_filter.cpp \
3232
bench/hashpadding.cpp \
33+
bench/logging.cpp \
3334
bench/merkle_root.cpp \
3435
bench/mempool_eviction.cpp \
3536
bench/mempool_stress.cpp \

‎src/bench/logging.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) 2020 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <bench/bench.h>
6+
#include <logging.h>
7+
#include <test/util/setup_common.h>
8+
9+
10+
static void Logging(benchmark::Bench& bench, const std::vector<const char*>& extra_args, const std::function<void()>& log)
11+
{
12+
TestingSetup test_setup{
13+
CBaseChainParams::REGTEST,
14+
extra_args,
15+
};
16+
17+
bench.run([&] { log(); });
18+
}
19+
20+
static void LoggingYoThreadNames(benchmark::Bench& bench)
21+
{
22+
Logging(bench, {"-logthreadnames=1"}, [] { LogPrintf("%s\n", "test"); });
23+
}
24+
static void LoggingNoThreadNames(benchmark::Bench& bench)
25+
{
26+
Logging(bench, {"-logthreadnames=0"}, [] { LogPrintf("%s\n", "test"); });
27+
}
28+
static void LoggingYoCategory(benchmark::Bench& bench)
29+
{
30+
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
31+
}
32+
static void LoggingNoCategory(benchmark::Bench& bench)
33+
{
34+
Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
35+
}
36+
static void LoggingNoFile(benchmark::Bench& bench)
37+
{
38+
Logging(bench, {"-nodebuglogfile", "-debug=1"}, [] {
39+
LogPrintf("%s\n", "test");
40+
LogPrint(BCLog::NET, "%s\n", "test");
41+
});
42+
}
43+
44+
BENCHMARK(LoggingYoThreadNames);
45+
BENCHMARK(LoggingNoThreadNames);
46+
BENCHMARK(LoggingYoCategory);
47+
BENCHMARK(LoggingNoCategory);
48+
BENCHMARK(LoggingNoFile);

0 commit comments

Comments
 (0)
Please sign in to comment.