mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
Merge bitcoin/bitcoin#18815: bench: Add logging benchmark
fafe06c379
bench: Sort bench_bench_bitcoin_SOURCES (MarcoFalke)fa31dc9b71
bench: Add logging benchmark (MarcoFalke) Pull request description: Might make finding performance bottlenecks or regressions (https://github.com/bitcoin/bitcoin/pull/17218) easier. For example, fuzzing relies on disabled logging to be as fast as possible. ACKs for top commit: dergoegge: ACKfafe06c379
Tree-SHA512: dd858f3234a4dfb00bd7dec4398eb076370a4b9746aa24eecee7da86f6882398a2d086e5ab0b7c9f7321abcb135e7ffc54cc78e60d18b90379c6dba6d613b3f7
This commit is contained in:
commit
e4d61d9759
2 changed files with 66 additions and 17 deletions
|
@ -13,38 +13,39 @@ GENERATED_BENCH_FILES = $(RAW_BENCH_FILES:.raw=.raw.h)
|
|||
bench_bench_bitcoin_SOURCES = \
|
||||
$(RAW_BENCH_FILES) \
|
||||
bench/addrman.cpp \
|
||||
bench/bench_bitcoin.cpp \
|
||||
bench/base58.cpp \
|
||||
bench/bech32.cpp \
|
||||
bench/bench.cpp \
|
||||
bench/bench.h \
|
||||
bench/bench_bitcoin.cpp \
|
||||
bench/block_assemble.cpp \
|
||||
bench/checkblock.cpp \
|
||||
bench/checkqueue.cpp \
|
||||
bench/data.h \
|
||||
bench/data.cpp \
|
||||
bench/duplicate_inputs.cpp \
|
||||
bench/examples.cpp \
|
||||
bench/rollingbloom.cpp \
|
||||
bench/ccoins_caching.cpp \
|
||||
bench/chacha20.cpp \
|
||||
bench/chacha_poly_aead.cpp \
|
||||
bench/checkblock.cpp \
|
||||
bench/checkqueue.cpp \
|
||||
bench/crypto_hash.cpp \
|
||||
bench/ccoins_caching.cpp \
|
||||
bench/data.cpp \
|
||||
bench/data.h \
|
||||
bench/duplicate_inputs.cpp \
|
||||
bench/examples.cpp \
|
||||
bench/gcs_filter.cpp \
|
||||
bench/hashpadding.cpp \
|
||||
bench/merkle_root.cpp \
|
||||
bench/lockedpool.cpp \
|
||||
bench/logging.cpp \
|
||||
bench/mempool_eviction.cpp \
|
||||
bench/mempool_stress.cpp \
|
||||
bench/nanobench.h \
|
||||
bench/merkle_root.cpp \
|
||||
bench/nanobench.cpp \
|
||||
bench/nanobench.h \
|
||||
bench/peer_eviction.cpp \
|
||||
bench/poly1305.cpp \
|
||||
bench/prevector.cpp \
|
||||
bench/rollingbloom.cpp \
|
||||
bench/rpc_blockchain.cpp \
|
||||
bench/rpc_mempool.cpp \
|
||||
bench/util_time.cpp \
|
||||
bench/verify_script.cpp \
|
||||
bench/base58.cpp \
|
||||
bench/bech32.cpp \
|
||||
bench/lockedpool.cpp \
|
||||
bench/poly1305.cpp \
|
||||
bench/prevector.cpp
|
||||
bench/verify_script.cpp
|
||||
|
||||
nodist_bench_bench_bitcoin_SOURCES = $(GENERATED_BENCH_FILES)
|
||||
|
||||
|
|
48
src/bench/logging.cpp
Normal file
48
src/bench/logging.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) 2020 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bench/bench.h>
|
||||
#include <logging.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
|
||||
static void Logging(benchmark::Bench& bench, const std::vector<const char*>& extra_args, const std::function<void()>& log)
|
||||
{
|
||||
TestingSetup test_setup{
|
||||
CBaseChainParams::REGTEST,
|
||||
extra_args,
|
||||
};
|
||||
|
||||
bench.run([&] { log(); });
|
||||
}
|
||||
|
||||
static void LoggingYoThreadNames(benchmark::Bench& bench)
|
||||
{
|
||||
Logging(bench, {"-logthreadnames=1"}, [] { LogPrintf("%s\n", "test"); });
|
||||
}
|
||||
static void LoggingNoThreadNames(benchmark::Bench& bench)
|
||||
{
|
||||
Logging(bench, {"-logthreadnames=0"}, [] { LogPrintf("%s\n", "test"); });
|
||||
}
|
||||
static void LoggingYoCategory(benchmark::Bench& bench)
|
||||
{
|
||||
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
|
||||
}
|
||||
static void LoggingNoCategory(benchmark::Bench& bench)
|
||||
{
|
||||
Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
|
||||
}
|
||||
static void LoggingNoFile(benchmark::Bench& bench)
|
||||
{
|
||||
Logging(bench, {"-nodebuglogfile", "-debug=1"}, [] {
|
||||
LogPrintf("%s\n", "test");
|
||||
LogPrint(BCLog::NET, "%s\n", "test");
|
||||
});
|
||||
}
|
||||
|
||||
BENCHMARK(LoggingYoThreadNames);
|
||||
BENCHMARK(LoggingNoThreadNames);
|
||||
BENCHMARK(LoggingYoCategory);
|
||||
BENCHMARK(LoggingNoCategory);
|
||||
BENCHMARK(LoggingNoFile);
|
Loading…
Reference in a new issue