Changeset View
Changeset View
Standalone View
Standalone View
src/bench/coin_selection.cpp
Show All 30 Lines | |||||
// to build up more complicated scenarios in order to get meaningful | // to build up more complicated scenarios in order to get meaningful | ||||
// measurements of performance. From laanwj, "Wallet coin selection is probably | // measurements of performance. From laanwj, "Wallet coin selection is probably | ||||
// 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); | ||||
const CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | const CWallet wallet(Params(), "dummy", WalletDatabase::CreateDummy()); | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
// Add coins. | // Add coins. | ||||
std::vector<OutputGroup> groups; | std::vector<OutputGroup> groups; | ||||
for (int i = 0; i < 1000; ++i) { | for (int i = 0; i < 1000; ++i) { | ||||
addCoin(1000 * COIN, wallet, groups); | addCoin(1000 * COIN, wallet, groups); | ||||
} | } | ||||
addCoin(3 * COIN, wallet, groups); | addCoin(3 * COIN, wallet, groups); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | for (int i = 0; i < utxos; ++i) { | ||||
add_coin(wallet, base + (int64_t(1) << (utxos - 1 - i)) * SATOSHI, | add_coin(wallet, base + (int64_t(1) << (utxos - 1 - i)) * SATOSHI, | ||||
2 * i + 1, utxo_pool); | 2 * i + 1, utxo_pool); | ||||
} | } | ||||
return target; | return target; | ||||
} | } | ||||
static void BnBExhaustion(benchmark::State &state) { | static void BnBExhaustion(benchmark::State &state) { | ||||
SelectParams(CBaseChainParams::REGTEST); | SelectParams(CBaseChainParams::REGTEST); | ||||
const CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | const CWallet wallet(Params(), "dummy", 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(); | ||||
Amount not_input_fees = Amount::zero(); | Amount not_input_fees = Amount::zero(); | ||||
Show All 15 Lines |