Skip to content

Commit

Permalink
cmake: Build bench_bitcoin executable
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed May 19, 2023
1 parent a2c3493 commit 751453f
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ tristate_option(WITH_USDT
AUTO
)

option(BUILD_BENCH "Build bench_bitcoin executable." ON)

if(CXX20)
set(CMAKE_CXX_STANDARD 20)
else()
Expand Down Expand Up @@ -172,6 +174,8 @@ message(" NAT-PMP ............................. ${WITH_NATPMP}")
message(" UPnP ................................ ${WITH_MINIUPNPC}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
message(" USDT tracing ........................ ${WITH_USDT}")
message("Tests:")
message(" bench_bitcoin ....................... ${BUILD_BENCH}")
message("")
if(CMAKE_CROSSCOMPILING)
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,9 @@ if(BUILD_UTIL)
bitcoin_util
)
endif()


add_subdirectory(test/util)
if(BUILD_BENCH)
add_subdirectory(bench)
endif()
64 changes: 64 additions & 0 deletions src/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2023 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(GenerateHeaders)
generate_header_from_raw(data/block413567.raw)

add_executable(bench_bitcoin
bench_bitcoin.cpp
bench.cpp
data.cpp
nanobench.cpp
${CMAKE_CURRENT_BINARY_DIR}/data/block413567.raw.h
# Benchmarks:
addrman.cpp
base58.cpp
bech32.cpp
block_assemble.cpp
ccoins_caching.cpp
chacha20.cpp
chacha_poly_aead.cpp
checkblock.cpp
checkqueue.cpp
crypto_hash.cpp
descriptors.cpp
duplicate_inputs.cpp
examples.cpp
gcs_filter.cpp
hashpadding.cpp
load_external.cpp
lockedpool.cpp
logging.cpp
mempool_eviction.cpp
mempool_stress.cpp
merkle_root.cpp
peer_eviction.cpp
poly1305.cpp
pool.cpp
prevector.cpp
rollingbloom.cpp
rpc_blockchain.cpp
rpc_mempool.cpp
strencodings.cpp
util_time.cpp
verify_script.cpp
)

target_link_libraries(bench_bitcoin
test_util
leveldb
univalue
Boost::headers
)

if(ENABLE_WALLET)
target_sources(bench_bitcoin
PRIVATE
coin_selection.cpp
wallet_balance.cpp
wallet_create_tx.cpp
wallet_loading.cpp
)
target_link_libraries(bench_bitcoin bitcoin_wallet)
endif()
33 changes: 33 additions & 0 deletions src/test/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

add_library(test_util STATIC EXCLUDE_FROM_ALL
blockfilter.cpp
coins.cpp
json.cpp
logging.cpp
mining.cpp
net.cpp
script.cpp
setup_common.cpp
str.cpp
transaction_utils.cpp
txmempool.cpp
validation.cpp
)
target_link_libraries(test_util
PRIVATE
bitcoin_common
bitcoin_node
leveldb
univalue
Boost::headers
)

if(ENABLE_WALLET)
target_sources(test_util
PRIVATE
../../wallet/test/util.cpp
)
endif()

0 comments on commit 751453f

Please sign in to comment.