diff --git a/CMakeLists.txt b/CMakeLists.txt index 99a90201da097..ef50903b95749 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() @@ -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}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 219939115b7a7..e61140c0e7737 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -276,3 +276,9 @@ if(BUILD_UTIL) bitcoin_util ) endif() + + +add_subdirectory(test/util) +if(BUILD_BENCH) + add_subdirectory(bench) +endif() diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt new file mode 100644 index 0000000000000..eba9b2535af44 --- /dev/null +++ b/src/bench/CMakeLists.txt @@ -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() diff --git a/src/test/util/CMakeLists.txt b/src/test/util/CMakeLists.txt new file mode 100644 index 0000000000000..3d3792cea4fac --- /dev/null +++ b/src/test/util/CMakeLists.txt @@ -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()