[BROKEN] Adapt existing benchmarks to CA

This commit is contained in:
Steven Roose 2019-03-19 20:47:21 +00:00
parent 703db5b42f
commit f4553d4b6d
No known key found for this signature in database
GPG key ID: 7FC91380BB4CE800
4 changed files with 24 additions and 8 deletions

View file

@ -95,7 +95,7 @@ static void AssembleBlock(benchmark::State& state)
tx.vin.push_back(MineBlock(SCRIPT_PUB));
tx.witness.vtxinwit.resize(1);
tx.witness.vtxinwit.back().scriptWitness = witness;
tx.vout.emplace_back(1337, SCRIPT_PUB);
tx.vout.emplace_back(CTxOut(CAsset(), 1337, SCRIPT_PUB));
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
txs.at(b) = MakeTransactionRef(tx);
}

View file

@ -45,11 +45,12 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state)
// Make insecure_rand here so that each iteration is identical.
FastRandomContext insecure_rand(true);
CCheckQueueControl<PrevectorJob> control(&queue);
std::vector<std::vector<PrevectorJob>> vBatches(BATCHES);
std::vector<std::vector<PrevectorJob*>> vBatches(BATCHES);
for (auto& vChecks : vBatches) {
vChecks.reserve(BATCH_SIZE);
for (size_t x = 0; x < BATCH_SIZE; ++x)
vChecks.emplace_back(insecure_rand);
for (size_t x = 0; x < BATCH_SIZE; ++x) {
vChecks.emplace_back(new PrevectorJob(insecure_rand));
}
control.Add(vChecks);
}
// control waits for completion by RAII, but

View file

@ -5,6 +5,8 @@
#include <bench/bench.h>
#include <wallet/wallet.h>
#include <wallet/coinselection.h>
#include <asset.h>
#include <policy/policy.h>
#include <set>
@ -47,12 +49,23 @@ static void CoinSelection(benchmark::State& state)
const CoinSelectionParams coin_selection_params(true, 34, 148, CFeeRate(0), 0);
while (state.KeepRunning()) {
std::set<CInputCoin> setCoinsRet;
CAmount nValueRet;
CAmountMap mapValueRet;
bool bnb_used;
bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used);
CAmountMap mapValue;
mapValue[::policyAsset] = 1003 * COIN;
bool success = wallet.SelectCoinsMinConf(mapValue, filter_standard, groups, setCoinsRet, mapValueRet, coin_selection_params, bnb_used);
assert(success);
assert(nValueRet == 1003 * COIN);
assert(mapValueRet[::policyAsset] == 1003 * COIN);
assert(setCoinsRet.size() == 2);
/* std::set<std::pair<const CWalletTx*, unsigned int> > setCoinsRet;
CAmountMap nValueRet;
CAmountMap mapValue;
mapValue[CAsset()] = 1003 * COIN;
bool success = wallet.SelectCoinsMinConf(mapValue, 1, 6, 0, vCoins, setCoinsRet, nValueRet);
assert(success);
assert(nValueRet[CAsset()] == 1003 * COIN);
assert(setCoinsRet.size() == 2);*/
}
}

View file

@ -97,10 +97,12 @@ static void VerifyScriptBench(benchmark::State& state)
#if defined(HAVE_CONSENSUS_LIB)
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << txSpend;
CDataStream streamVal(SER_NETWORK, PROTOCOL_VERSION);
streamVal << txCredit.vout[0].nValue;
int csuccess = bitcoinconsensus_verify_script_with_amount(
txCredit.vout[0].scriptPubKey.data(),
txCredit.vout[0].scriptPubKey.size(),
txCredit.vout[0].nValue,
(const unsigned char*)&streamVal[0], streamVal.size(),
(const unsigned char*)stream.data(), stream.size(), 0, flags, nullptr);
assert(csuccess == 1);
#endif