|
| 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