From fa31dc9b714401b67480232ef552d1479f5e6902 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 29 Apr 2020 15:05:41 +0200 Subject: [PATCH 1/2] bench: Add logging benchmark --- src/Makefile.bench.include | 1 + src/bench/logging.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/bench/logging.cpp diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 2a8e4a0aac..5835c77184 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -30,6 +30,7 @@ bench_bench_bitcoin_SOURCES = \ bench/ccoins_caching.cpp \ bench/gcs_filter.cpp \ bench/hashpadding.cpp \ + bench/logging.cpp \ bench/merkle_root.cpp \ bench/mempool_eviction.cpp \ bench/mempool_stress.cpp \ diff --git a/src/bench/logging.cpp b/src/bench/logging.cpp new file mode 100644 index 0000000000..d28777df9e --- /dev/null +++ b/src/bench/logging.cpp @@ -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 +#include +#include + + +static void Logging(benchmark::Bench& bench, const std::vector& extra_args, const std::function& 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); From fafe06c379316f165e88b8de7300a716cef25d0a Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 29 Apr 2020 15:13:14 +0200 Subject: [PATCH 2/2] bench: Sort bench_bench_bitcoin_SOURCES --- src/Makefile.bench.include | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 5835c77184..e6cb331c34 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -13,39 +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/lockedpool.cpp \ bench/logging.cpp \ - bench/merkle_root.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)