Skip to content

Commit e4d61d9

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#18815: bench: Add logging benchmark
fafe06c bench: Sort bench_bench_bitcoin_SOURCES (MarcoFalke) fa31dc9 bench: Add logging benchmark (MarcoFalke) Pull request description: Might make finding performance bottlenecks or regressions (bitcoin/bitcoin#17218) easier. For example, fuzzing relies on disabled logging to be as fast as possible. ACKs for top commit: dergoegge: ACK fafe06c Tree-SHA512: dd858f3234a4dfb00bd7dec4398eb076370a4b9746aa24eecee7da86f6882398a2d086e5ab0b7c9f7321abcb135e7ffc54cc78e60d18b90379c6dba6d613b3f7
2 parents ee47800 + fafe06c commit e4d61d9

File tree

2 files changed

+64
-15
lines changed

2 files changed

+64
-15
lines changed

src/Makefile.bench.include

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,39 @@ GENERATED_BENCH_FILES = $(RAW_BENCH_FILES:.raw=.raw.h)
1313
bench_bench_bitcoin_SOURCES = \
1414
$(RAW_BENCH_FILES) \
1515
bench/addrman.cpp \
16-
bench/bench_bitcoin.cpp \
16+
bench/base58.cpp \
17+
bench/bech32.cpp \
1718
bench/bench.cpp \
1819
bench/bench.h \
20+
bench/bench_bitcoin.cpp \
1921
bench/block_assemble.cpp \
22+
bench/ccoins_caching.cpp \
23+
bench/chacha20.cpp \
24+
bench/chacha_poly_aead.cpp \
2025
bench/checkblock.cpp \
2126
bench/checkqueue.cpp \
22-
bench/data.h \
27+
bench/crypto_hash.cpp \
2328
bench/data.cpp \
29+
bench/data.h \
2430
bench/duplicate_inputs.cpp \
2531
bench/examples.cpp \
26-
bench/rollingbloom.cpp \
27-
bench/chacha20.cpp \
28-
bench/chacha_poly_aead.cpp \
29-
bench/crypto_hash.cpp \
30-
bench/ccoins_caching.cpp \
3132
bench/gcs_filter.cpp \
3233
bench/hashpadding.cpp \
33-
bench/merkle_root.cpp \
34+
bench/lockedpool.cpp \
35+
bench/logging.cpp \
3436
bench/mempool_eviction.cpp \
3537
bench/mempool_stress.cpp \
36-
bench/nanobench.h \
38+
bench/merkle_root.cpp \
3739
bench/nanobench.cpp \
40+
bench/nanobench.h \
3841
bench/peer_eviction.cpp \
42+
bench/poly1305.cpp \
43+
bench/prevector.cpp \
44+
bench/rollingbloom.cpp \
3945
bench/rpc_blockchain.cpp \
4046
bench/rpc_mempool.cpp \
4147
bench/util_time.cpp \
42-
bench/verify_script.cpp \
43-
bench/base58.cpp \
44-
bench/bech32.cpp \
45-
bench/lockedpool.cpp \
46-
bench/poly1305.cpp \
47-
bench/prevector.cpp
48+
bench/verify_script.cpp
4849

4950
nodist_bench_bench_bitcoin_SOURCES = $(GENERATED_BENCH_FILES)
5051

src/bench/logging.cpp

Lines changed: 48 additions & 0 deletions
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)