Bitcoin Core  24.99.0
P2P Digital Currency
logging.cpp
Go to the documentation of this file.
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>
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{
14  extra_args,
15  };
16 
17  bench.run([&] { log(); });
18 }
19 
21 {
22  Logging(bench, {"-logthreadnames=1"}, [] { LogPrintf("%s\n", "test"); });
23 }
25 {
26  Logging(bench, {"-logthreadnames=0"}, [] { LogPrintf("%s\n", "test"); });
27 }
29 {
30  Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogPrint(BCLog::NET, "%s\n", "test"); });
31 }
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 
static void LoggingNoCategory(benchmark::Bench &bench)
Definition: logging.cpp:32
static void LoggingNoThreadNames(benchmark::Bench &bench)
Definition: logging.cpp:24
BENCHMARK(LoggingYoThreadNames)
static void LoggingNoFile(benchmark::Bench &bench)
Definition: logging.cpp:36
static void LoggingYoCategory(benchmark::Bench &bench)
Definition: logging.cpp:28
static void Logging(benchmark::Bench &bench, const std::vector< const char * > &extra_args, const std::function< void()> &log)
Definition: logging.cpp:10
static void LoggingYoThreadNames(benchmark::Bench &bench)
Definition: logging.cpp:20
static const std::string REGTEST
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:616
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1183
#define LogPrint(category,...)
Definition: logging.h:243
#define LogPrintf(...)
Definition: logging.h:234
@ NET
Definition: logging.h:40
Testing setup that configures a complete environment.
Definition: setup_common.h:109