Benchmark time to call sendtoaddress with many UTXOs

This commit is contained in:
Jack Grigg
2017-08-17 10:31:47 +01:00
parent 02dd675a25
commit a76174b76b
5 changed files with 157 additions and 9 deletions

View File

@@ -2596,6 +2596,12 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
}
sample_times.push_back(benchmark_connectblock_slow());
} else if (benchmarktype == "sendtoaddress") {
if (Params().NetworkIDString() != "regtest") {
throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
}
auto amount = AmountFromValue(params[2]);
sample_times.push_back(benchmark_sendtoaddress(amount));
} else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype");
}

View File

@@ -17,6 +17,7 @@
#include "main.h"
#include "miner.h"
#include "pow.h"
#include "rpcserver.h"
#include "script/sign.h"
#include "sodium.h"
#include "streams.h"
@@ -405,3 +406,17 @@ double benchmark_connectblock_slow()
return duration;
}
double benchmark_sendtoaddress(CAmount amount)
{
UniValue params(UniValue::VARR);
auto addr = getnewaddress(params, false);
params.push_back(addr);
params.push_back(ValueFromAmount(amount));
struct timeval tv_start;
timer_start(tv_start);
auto txid = sendtoaddress(params, false);
return timer_stop(tv_start);
}

View File

@@ -16,5 +16,6 @@ extern double benchmark_large_tx();
extern double benchmark_try_decrypt_notes(size_t nAddrs);
extern double benchmark_increment_note_witnesses(size_t nTxs);
extern double benchmark_connectblock_slow();
extern double benchmark_sendtoaddress(CAmount amount);
#endif