Skip to content

Commit 8bb0e85

Browse files
committed
cmake: Build bench_bitcoin executable
1 parent 8017351 commit 8bb0e85

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ endif()
140140

141141
cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." ON "NOT WIN32" OFF)
142142

143+
option(BUILD_BENCH "Build bench_bitcoin executable." OFF)
144+
143145
set(configure_warnings)
144146

145147
include(CheckPIESupported)
@@ -264,7 +266,7 @@ target_link_libraries(core_interface INTERFACE
264266
include(AddBoostIfNeeded)
265267
add_boost_if_needed()
266268

267-
if(BUILD_DAEMON OR BUILD_CLI OR BUILD_TESTS)
269+
if(BUILD_DAEMON OR BUILD_CLI OR BUILD_TESTS OR BUILD_BENCH)
268270
find_package(Libevent 2.1.8 MODULE REQUIRED)
269271
endif()
270272

@@ -320,6 +322,7 @@ message(" ZeroMQ .............................. ${WITH_ZMQ}")
320322
message(" USDT tracing ........................ ${WITH_USDT}")
321323
message("Tests:")
322324
message(" test_bitcoin ........................ ${BUILD_TESTS}")
325+
message(" bench_bitcoin ....................... ${BUILD_BENCH}")
323326
message("")
324327
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}")
325328
include(FlagsSummary)

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ endif()
339339

340340

341341
add_subdirectory(test/util)
342+
if(BUILD_BENCH)
343+
add_subdirectory(bench)
344+
endif()
345+
342346
if(BUILD_TESTS)
343347
add_subdirectory(test)
344348
endif()

src/bench/CMakeLists.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2023-present The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
include(GenerateHeaders)
6+
generate_header_from_raw(data/block413567.raw)
7+
8+
add_executable(bench_bitcoin
9+
bench_bitcoin.cpp
10+
bench.cpp
11+
data.cpp
12+
nanobench.cpp
13+
${CMAKE_CURRENT_BINARY_DIR}/data/block413567.raw.h
14+
# Benchmarks:
15+
addrman.cpp
16+
base58.cpp
17+
bech32.cpp
18+
bip324_ecdh.cpp
19+
block_assemble.cpp
20+
ccoins_caching.cpp
21+
chacha20.cpp
22+
checkblock.cpp
23+
checkblockindex.cpp
24+
checkqueue.cpp
25+
cluster_linearize.cpp
26+
crypto_hash.cpp
27+
descriptors.cpp
28+
disconnected_transactions.cpp
29+
duplicate_inputs.cpp
30+
ellswift.cpp
31+
examples.cpp
32+
gcs_filter.cpp
33+
hashpadding.cpp
34+
index_blockfilter.cpp
35+
load_external.cpp
36+
lockedpool.cpp
37+
logging.cpp
38+
mempool_eviction.cpp
39+
mempool_stress.cpp
40+
merkle_root.cpp
41+
parse_hex.cpp
42+
peer_eviction.cpp
43+
poly1305.cpp
44+
pool.cpp
45+
prevector.cpp
46+
random.cpp
47+
readblock.cpp
48+
rollingbloom.cpp
49+
rpc_blockchain.cpp
50+
rpc_mempool.cpp
51+
sign_transaction.cpp
52+
streams_findbyte.cpp
53+
strencodings.cpp
54+
util_time.cpp
55+
verify_script.cpp
56+
xor.cpp
57+
)
58+
59+
target_link_libraries(bench_bitcoin
60+
core_interface
61+
test_util
62+
bitcoin_node
63+
Boost::headers
64+
)
65+
66+
if(ENABLE_WALLET)
67+
target_sources(bench_bitcoin
68+
PRIVATE
69+
coin_selection.cpp
70+
wallet_balance.cpp
71+
wallet_create.cpp
72+
wallet_create_tx.cpp
73+
wallet_loading.cpp
74+
wallet_ismine.cpp
75+
)
76+
target_link_libraries(bench_bitcoin bitcoin_wallet)
77+
endif()
78+
79+
add_test(NAME bench_sanity_check_high_priority
80+
COMMAND bench_bitcoin -sanity-check -priority-level=high
81+
)

0 commit comments

Comments
 (0)