Changeset View
Changeset View
Standalone View
Standalone View
src/bench/coin_selection.cpp
Show All 29 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()); | const CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | ||||
std::vector<COutput> vCoins; | std::vector<COutput> vCoins; | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
// Add coins. | // Add coins. | ||||
for (int i = 0; i < 1000; i++) | for (int i = 0; i < 1000; i++) | ||||
addCoin(1000 * COIN, wallet, vCoins); | addCoin(1000 * COIN, wallet, vCoins); | ||||
addCoin(3 * COIN, wallet, vCoins); | addCoin(3 * COIN, wallet, vCoins); | ||||
Show All 18 Lines |