Add automated performance measurement system.

This commit is contained in:
Taylor Hornby
2016-04-07 15:37:39 -06:00
parent c34d662f10
commit 6962bb3df0
8 changed files with 258 additions and 1 deletions

View File

@@ -17,6 +17,7 @@
#include "wallet.h"
#include "walletdb.h"
#include "primitives/transaction.h"
#include "zcbenchmarks.h"
#include <stdint.h>
@@ -2345,6 +2346,76 @@ Value listunspent(const Array& params, bool fHelp)
return results;
}
Value zc_benchmark(const json_spirit::Array& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp)) {
return Value::null;
}
if (fHelp || params.size() < 2) {
throw runtime_error(
"zcbenchmark benchmarktype samplecount\n"
"\n"
"Runs a benchmark of the selected type samplecount times,\n"
"returning the running times of each sample.\n"
"\n"
"Output: [\n"
" {\n"
" \"runningtime\": runningtime\n"
" },\n"
" {\n"
" \"runningtime\": runningtime\n"
" }\n"
" ...\n"
"]\n"
);
}
LOCK(cs_main);
std::string benchmarktype = params[0].get_str();
int samplecount = params[1].get_int();
if (samplecount <= 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid samplecount");
}
std::vector<double> sample_times;
if (benchmarktype == "createjoinsplit") {
/* Load the proving now key so that it doesn't happen as part of the
* first joinsplit. */
pzerocashParams->loadProvingKey();
}
for (int i = 0; i < samplecount; i++) {
if (benchmarktype == "sleep") {
sample_times.push_back(benchmark_sleep());
} else if (benchmarktype == "parameterloading") {
sample_times.push_back(benchmark_parameter_loading());
} else if (benchmarktype == "createjoinsplit") {
sample_times.push_back(benchmark_create_joinsplit());
} else if (benchmarktype == "verifyjoinsplit") {
throw JSONRPCError(RPC_TYPE_ERROR, "Unimplemented");
} else if (benchmarktype == "equihashsolve") {
throw JSONRPCError(RPC_TYPE_ERROR, "Unimplemented");
} else if (benchmarktype == "equihashverify") {
throw JSONRPCError(RPC_TYPE_ERROR, "Unimplemented");
} else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype");
}
}
Array results;
for (int i = 0; i < samplecount; i++) {
Object result;
result.push_back(Pair("runningtime", sample_times.at(i)));
results.push_back(result);
}
return results;
}
Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp)) {