mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 03:33:27 -03:00
bench: Add logging benchmark
This commit is contained in:
parent
60b5795133
commit
fa31dc9b71
2 changed files with 49 additions and 0 deletions
|
@ -30,6 +30,7 @@ bench_bench_bitcoin_SOURCES = \
|
||||||
bench/ccoins_caching.cpp \
|
bench/ccoins_caching.cpp \
|
||||||
bench/gcs_filter.cpp \
|
bench/gcs_filter.cpp \
|
||||||
bench/hashpadding.cpp \
|
bench/hashpadding.cpp \
|
||||||
|
bench/logging.cpp \
|
||||||
bench/merkle_root.cpp \
|
bench/merkle_root.cpp \
|
||||||
bench/mempool_eviction.cpp \
|
bench/mempool_eviction.cpp \
|
||||||
bench/mempool_stress.cpp \
|
bench/mempool_stress.cpp \
|
||||||
|
|
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…
Add table
Reference in a new issue