Changeset View
Changeset View
Standalone View
Standalone View
src/bench/coin_selection.cpp
Show All 28 Lines | |||||
// the hardest, as you need a wider selection of scenarios, just testing the | // the hardest, as you need a wider selection of scenarios, just testing the | ||||
// same one over and over isn't too useful. Generating random isn't useful | // same one over and over isn't too useful. Generating random isn't useful | ||||
// either for measurements." | // either for measurements." | ||||
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484) | // (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484) | ||||
static void CoinSelection(benchmark::State &state) { | static void CoinSelection(benchmark::State &state) { | ||||
SelectParams(CBaseChainParams::REGTEST); | SelectParams(CBaseChainParams::REGTEST); | ||||
auto chain = interfaces::MakeChain(); | auto chain = interfaces::MakeChain(); | ||||
const CWallet wallet(Params(), *chain, WalletLocation(), | const CWallet wallet(Params(), chain.get(), WalletLocation(), | ||||
WalletDatabase::CreateDummy()); | WalletDatabase::CreateDummy()); | ||||
std::vector<std::unique_ptr<CWalletTx>> wtxs; | std::vector<std::unique_ptr<CWalletTx>> wtxs; | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
// Add coins. | // Add coins. | ||||
for (int i = 0; i < 1000; ++i) { | for (int i = 0; i < 1000; ++i) { | ||||
addCoin(1000 * COIN, wallet, wtxs); | addCoin(1000 * COIN, wallet, wtxs); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | static Amount make_hard_case(const CWallet &wallet, int utxos, | ||||
} | } | ||||
return target; | return target; | ||||
} | } | ||||
static void BnBExhaustion(benchmark::State &state) { | static void BnBExhaustion(benchmark::State &state) { | ||||
SelectParams(CBaseChainParams::REGTEST); | SelectParams(CBaseChainParams::REGTEST); | ||||
auto chain = interfaces::MakeChain(); | auto chain = interfaces::MakeChain(); | ||||
const CWallet wallet(Params(), *chain, WalletLocation(), | const CWallet wallet(Params(), chain.get(), WalletLocation(), | ||||
WalletDatabase::CreateDummy()); | WalletDatabase::CreateDummy()); | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
// Setup | // Setup | ||||
std::vector<OutputGroup> utxo_pool; | std::vector<OutputGroup> utxo_pool; | ||||
CoinSet selection; | CoinSet selection; | ||||
Amount value_ret = Amount::zero(); | Amount value_ret = Amount::zero(); | ||||
Show All 17 Lines |