Add equihash solving benchmarks

This commit is contained in:
Taylor Hornby 2016-04-11 08:05:13 -06:00
parent 6962bb3df0
commit bf8def9749
4 changed files with 35 additions and 6 deletions

View File

@ -3,12 +3,12 @@
set -e
function zcash_rpc {
./src/zcash-cli -rpcwait -rpcuser=user -rpcpassword=password -rpcport=5001 "$@"
./src/zcash-cli -rpcwait -rpcuser=user -rpcpassword=password -rpcport=5983 "$@"
}
function zcashd_start {
./src/zcashd -regtest -rpcuser=user -rpcpassword=password -rpcport=5001 &
./src/zcashd -regtest -rpcuser=user -rpcpassword=password -rpcport=5983 &
ZCASHD_PID=$!
}
@ -19,7 +19,7 @@ function zcashd_stop {
function zcashd_massif_start {
rm -f massif.out
valgrind --tool=massif --time-unit=ms --massif-out-file=massif.out ./src/zcashd -regtest -rpcuser=user -rpcpassword=password -rpcport=5001 &
valgrind --tool=massif --time-unit=ms --massif-out-file=massif.out ./src/zcashd -regtest -rpcuser=user -rpcpassword=password -rpcport=5983 &
ZCASHD_PID=$!
}
@ -54,6 +54,13 @@ zcashd_start
zcash_rpc zcbenchmark createjoinsplit 10
zcashd_stop
echo ""
echo "Solve Equihash"
echo "------------------"
zcashd_start
zcash_rpc zcbenchmark solveequihash 10
zcashd_stop
echo ""
echo ""
echo "Memory"
@ -79,3 +86,10 @@ echo "------------------"
zcashd_massif_start
zcash_rpc zcbenchmark createjoinsplit 1
zcashd_massif_stop
echo ""
echo "Solve Equihash"
echo "------------------"
zcashd_massif_start
zcash_rpc zcbenchmark solveequihash 10
zcashd_massif_stop

View File

@ -2397,9 +2397,9 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp)
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") {
} else if (benchmarktype == "solveequihash") {
sample_times.push_back(benchmark_solve_equihash());
} else if (benchmarktype == "verifyequihash") {
throw JSONRPCError(RPC_TYPE_ERROR, "Unimplemented");
} else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype");

View File

@ -5,6 +5,8 @@
#include "util.h"
#include "init.h"
#include "primitives/transaction.h"
#include "crypto/equihash.h"
#include "chainparams.h"
#include "zcbenchmarks.h"
@ -88,3 +90,15 @@ double benchmark_create_joinsplit()
assert(pourtx.Verify(*pzerocashParams));
return ret;
}
double benchmark_solve_equihash()
{
const char *testing = "testing";
Equihash eh {Params(CBaseChainParams::MAIN).EquihashN(), Params(CBaseChainParams::MAIN).EquihashK()};
crypto_generichash_blake2b_state eh_state;
eh.InitialiseState(eh_state);
crypto_generichash_blake2b_update(&eh_state, (const unsigned char*)testing, strlen(testing));
timer_start();
eh.BasicSolve(eh_state);
return timer_stop();
}

View File

@ -7,5 +7,6 @@
extern double benchmark_sleep();
extern double benchmark_parameter_loading();
extern double benchmark_create_joinsplit();
extern double benchmark_solve_equihash();
#endif