Skip to content

Commit b43f6c9

Browse files
MarcoFalkeknst
authored andcommitted
Merge 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#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
1 parent 6ea60b0 commit b43f6c9

File tree

2 files changed

+63
-14
lines changed

2 files changed

+63
-14
lines changed

src/Makefile.bench.include

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,47 @@ GENERATED_BENCH_FILES = $(RAW_BENCH_FILES:.raw=.raw.h)
1414
bench_bench_dash_SOURCES = \
1515
$(RAW_BENCH_FILES) \
1616
bench/addrman.cpp \
17-
bench/bench_bitcoin.cpp \
17+
bench/base58.cpp \
18+
bench/bech32.cpp \
1819
bench/bench.cpp \
1920
bench/bench.h \
21+
bench/bench_bitcoin.cpp \
2022
bench/bip324_ecdh.cpp \
2123
bench/block_assemble.cpp \
2224
bench/bls.cpp \
2325
bench/bls_dkg.cpp \
26+
bench/ccoins_caching.cpp \
27+
bench/chacha20.cpp \
2428
bench/checkblock.cpp \
2529
bench/checkqueue.cpp \
26-
bench/data.h \
30+
bench/crypto_hash.cpp \
2731
bench/data.cpp \
32+
bench/data.h \
2833
bench/duplicate_inputs.cpp \
2934
bench/ecdsa.cpp \
3035
bench/ellswift.cpp \
3136
bench/examples.cpp \
32-
bench/rollingbloom.cpp \
33-
bench/chacha20.cpp \
34-
bench/crypto_hash.cpp \
35-
bench/ccoins_caching.cpp \
3637
bench/gcs_filter.cpp \
3738
bench/hashpadding.cpp \
39+
bench/logging.cpp \
3840
bench/load_external.cpp \
39-
bench/merkle_root.cpp \
41+
bench/lockedpool.cpp \
4042
bench/mempool_eviction.cpp \
4143
bench/mempool_stress.cpp \
42-
bench/nanobench.h \
44+
bench/merkle_root.cpp \
4345
bench/nanobench.cpp \
46+
bench/nanobench.h \
4447
bench/peer_eviction.cpp \
48+
bench/poly1305.cpp \
4549
bench/pool.cpp \
4650
bench/pow_hash.cpp \
51+
bench/prevector.cpp \
52+
bench/rollingbloom.cpp \
4753
bench/rpc_blockchain.cpp \
4854
bench/rpc_mempool.cpp \
4955
bench/strencodings.cpp \
50-
bench/util_time.cpp \
51-
bench/base58.cpp \
52-
bench/bech32.cpp \
53-
bench/lockedpool.cpp \
54-
bench/poly1305.cpp \
55-
bench/prevector.cpp \
5656
bench/string_cast.cpp \
57+
bench/util_time.cpp \
5758
bench/verify_script.cpp
5859

5960
nodist_bench_bench_dash_SOURCES = $(GENERATED_BENCH_FILES)

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)