Skip to content

Commit

Permalink
[BROKEN] Adapt existing benchmarks to CA
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Mar 20, 2019
1 parent 703db5b commit f4553d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/bench/checkqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 16 additions & 3 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);*/
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/bench/verify_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4553d4

Please sign in to comment.