Changeset View
Changeset View
Standalone View
Standalone View
src/bench/coin_selection.cpp
| // Copyright (c) 2012-2016 The Bitcoin Core developers | // Copyright (c) 2012-2016 The Bitcoin Core developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| #include "bench.h" | #include "bench.h" | ||||
| #include "chainparams.h" | |||||
| #include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
| #include <set> | #include <set> | ||||
| static void addCoin(const Amount nValue, const CWallet &wallet, | static void addCoin(const Amount nValue, const CWallet &wallet, | ||||
| std::vector<COutput> &vCoins) { | std::vector<COutput> &vCoins) { | ||||
| int nInput = 0; | int nInput = 0; | ||||
| Show All 14 Lines | |||||
| // Simple benchmark for wallet coin selection. Note that it maybe be necessary | // Simple benchmark for wallet coin selection. Note that it maybe be necessary | ||||
| // 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) { | ||||
| const CWallet wallet; | const CWallet wallet(Params()); | ||||
| std::vector<COutput> vCoins; | std::vector<COutput> vCoins; | ||||
| LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
| while (state.KeepRunning()) { | while (state.KeepRunning()) { | ||||
| // Empty wallet. | // Empty wallet. | ||||
| for (COutput output : vCoins) { | for (COutput output : vCoins) { | ||||
| delete output.tx; | delete output.tx; | ||||
| } | } | ||||
| Show All 19 Lines | |||||