@@ -74,7 +74,7 @@ case "$1" in
|
|||||||
zcash_rpc zcbenchmark parameterloading 10
|
zcash_rpc zcbenchmark parameterloading 10
|
||||||
;;
|
;;
|
||||||
createjoinsplit)
|
createjoinsplit)
|
||||||
zcash_rpc zcbenchmark createjoinsplit 10
|
zcash_rpc zcbenchmark createjoinsplit 10 "${@:3}"
|
||||||
;;
|
;;
|
||||||
verifyjoinsplit)
|
verifyjoinsplit)
|
||||||
zcash_rpc zcbenchmark verifyjoinsplit 1000 "\"$RAWJOINSPLIT\""
|
zcash_rpc zcbenchmark verifyjoinsplit 1000 "\"$RAWJOINSPLIT\""
|
||||||
@@ -111,7 +111,7 @@ case "$1" in
|
|||||||
zcash_rpc zcbenchmark parameterloading 1
|
zcash_rpc zcbenchmark parameterloading 1
|
||||||
;;
|
;;
|
||||||
createjoinsplit)
|
createjoinsplit)
|
||||||
zcash_rpc zcbenchmark createjoinsplit 1
|
zcash_rpc zcbenchmark createjoinsplit 1 "${@:3}"
|
||||||
;;
|
;;
|
||||||
verifyjoinsplit)
|
verifyjoinsplit)
|
||||||
zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\""
|
zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\""
|
||||||
@@ -146,7 +146,7 @@ case "$1" in
|
|||||||
zcash_rpc zcbenchmark parameterloading 1
|
zcash_rpc zcbenchmark parameterloading 1
|
||||||
;;
|
;;
|
||||||
createjoinsplit)
|
createjoinsplit)
|
||||||
zcash_rpc zcbenchmark createjoinsplit 1
|
zcash_rpc zcbenchmark createjoinsplit 1 "${@:3}"
|
||||||
;;
|
;;
|
||||||
verifyjoinsplit)
|
verifyjoinsplit)
|
||||||
zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\""
|
zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\""
|
||||||
|
|||||||
@@ -2465,7 +2465,15 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp)
|
|||||||
} else if (benchmarktype == "parameterloading") {
|
} else if (benchmarktype == "parameterloading") {
|
||||||
sample_times.push_back(benchmark_parameter_loading());
|
sample_times.push_back(benchmark_parameter_loading());
|
||||||
} else if (benchmarktype == "createjoinsplit") {
|
} else if (benchmarktype == "createjoinsplit") {
|
||||||
sample_times.push_back(benchmark_create_joinsplit());
|
if (params.size() < 3) {
|
||||||
|
sample_times.push_back(benchmark_create_joinsplit());
|
||||||
|
} else {
|
||||||
|
int nThreads = params[2].get_int();
|
||||||
|
std::vector<double> vals = benchmark_create_joinsplit_threaded(nThreads);
|
||||||
|
// Divide by nThreads^2 to get average seconds per JoinSplit because
|
||||||
|
// we are running one JoinSplit per thread.
|
||||||
|
sample_times.push_back(std::accumulate(vals.begin(), vals.end(), 0.0) / (nThreads*nThreads));
|
||||||
|
}
|
||||||
} else if (benchmarktype == "verifyjoinsplit") {
|
} else if (benchmarktype == "verifyjoinsplit") {
|
||||||
sample_times.push_back(benchmark_verify_joinsplit(samplejoinsplit));
|
sample_times.push_back(benchmark_verify_joinsplit(samplejoinsplit));
|
||||||
} else if (benchmarktype == "solveequihash") {
|
} else if (benchmarktype == "solveequihash") {
|
||||||
|
|||||||
@@ -95,6 +95,27 @@ double benchmark_create_joinsplit()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<double> benchmark_create_joinsplit_threaded(int nThreads)
|
||||||
|
{
|
||||||
|
std::vector<double> ret;
|
||||||
|
std::vector<std::future<double>> tasks;
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
for (int i = 0; i < nThreads; i++) {
|
||||||
|
std::packaged_task<double(void)> task(&benchmark_create_joinsplit);
|
||||||
|
tasks.emplace_back(task.get_future());
|
||||||
|
threads.emplace_back(std::move(task));
|
||||||
|
}
|
||||||
|
std::future_status status;
|
||||||
|
for (auto it = tasks.begin(); it != tasks.end(); it++) {
|
||||||
|
it->wait();
|
||||||
|
ret.push_back(it->get());
|
||||||
|
}
|
||||||
|
for (auto it = threads.begin(); it != threads.end(); it++) {
|
||||||
|
it->join();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
double benchmark_verify_joinsplit(const JSDescription &joinsplit)
|
double benchmark_verify_joinsplit(const JSDescription &joinsplit)
|
||||||
{
|
{
|
||||||
struct timeval tv_start;
|
struct timeval tv_start;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
extern double benchmark_sleep();
|
extern double benchmark_sleep();
|
||||||
extern double benchmark_parameter_loading();
|
extern double benchmark_parameter_loading();
|
||||||
extern double benchmark_create_joinsplit();
|
extern double benchmark_create_joinsplit();
|
||||||
|
extern std::vector<double> benchmark_create_joinsplit_threaded(int nThreads);
|
||||||
extern double benchmark_solve_equihash();
|
extern double benchmark_solve_equihash();
|
||||||
extern std::vector<double> benchmark_solve_equihash_threaded(int nThreads);
|
extern std::vector<double> benchmark_solve_equihash_threaded(int nThreads);
|
||||||
extern double benchmark_verify_joinsplit(const JSDescription &joinsplit);
|
extern double benchmark_verify_joinsplit(const JSDescription &joinsplit);
|
||||||
|
|||||||
Reference in New Issue
Block a user