Auto merge of #2613 - arielgabizon:load-wallet-benchmark, r=str4d
Add load-wallet benchmark Closes #2518.
This commit is contained in:
commit
6e9964ff70
|
@ -56,7 +56,7 @@ function use_200k_benchmark {
|
|||
|
||||
function zcashd_start {
|
||||
case "$1" in
|
||||
sendtoaddress)
|
||||
sendtoaddress|loadwallet)
|
||||
case "$2" in
|
||||
200k-recv)
|
||||
use_200k_benchmark 0
|
||||
|
@ -86,7 +86,7 @@ function zcashd_stop {
|
|||
|
||||
function zcashd_massif_start {
|
||||
case "$1" in
|
||||
sendtoaddress)
|
||||
sendtoaddress|loadwallet)
|
||||
case "$2" in
|
||||
200k-recv)
|
||||
use_200k_benchmark 0
|
||||
|
@ -203,6 +203,9 @@ case "$1" in
|
|||
sendtoaddress)
|
||||
zcash_rpc zcbenchmark sendtoaddress 10 "${@:4}"
|
||||
;;
|
||||
loadwallet)
|
||||
zcash_rpc zcbenchmark loadwallet 10
|
||||
;;
|
||||
*)
|
||||
zcashd_stop
|
||||
echo "Bad arguments."
|
||||
|
|
|
@ -2603,6 +2603,11 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp)
|
|||
}
|
||||
auto amount = AmountFromValue(params[2]);
|
||||
sample_times.push_back(benchmark_sendtoaddress(amount));
|
||||
} else if (benchmarktype == "loadwallet") {
|
||||
if (Params().NetworkIDString() != "regtest") {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Benchmark must be run in regtest mode");
|
||||
}
|
||||
sample_times.push_back(benchmark_loadwallet());
|
||||
} else {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype");
|
||||
}
|
||||
|
|
|
@ -31,6 +31,39 @@
|
|||
#include "zcash/IncrementalMerkleTree.hpp"
|
||||
|
||||
using namespace libzcash;
|
||||
// This method is based on Shutdown from init.cpp
|
||||
void pre_wallet_load()
|
||||
{
|
||||
LogPrintf("%s: In progress...\n", __func__);
|
||||
if (ShutdownRequested())
|
||||
throw new std::runtime_error("The node is shutting down");
|
||||
|
||||
if (pwalletMain)
|
||||
pwalletMain->Flush(false);
|
||||
#ifdef ENABLE_MINING
|
||||
GenerateBitcoins(false, NULL, 0);
|
||||
#endif
|
||||
UnregisterNodeSignals(GetNodeSignals());
|
||||
if (pwalletMain)
|
||||
pwalletMain->Flush(true);
|
||||
|
||||
UnregisterValidationInterface(pwalletMain);
|
||||
delete pwalletMain;
|
||||
pwalletMain = NULL;
|
||||
bitdb.Reset();
|
||||
RegisterNodeSignals(GetNodeSignals());
|
||||
LogPrintf("%s: done\n", __func__);
|
||||
}
|
||||
|
||||
void post_wallet_load(){
|
||||
RegisterValidationInterface(pwalletMain);
|
||||
#ifdef ENABLE_MINING
|
||||
// Generate coins in the background
|
||||
if (pwalletMain || !GetArg("-mineraddress", "").empty())
|
||||
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void timer_start(timeval &tv_start)
|
||||
{
|
||||
|
@ -420,3 +453,15 @@ double benchmark_sendtoaddress(CAmount amount)
|
|||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
double benchmark_loadwallet()
|
||||
{
|
||||
pre_wallet_load();
|
||||
struct timeval tv_start;
|
||||
bool fFirstRunRet=true;
|
||||
timer_start(tv_start);
|
||||
pwalletMain = new CWallet("wallet.dat");
|
||||
DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRunRet);
|
||||
auto res = timer_stop(tv_start);
|
||||
post_wallet_load();
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -17,5 +17,6 @@ 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);
|
||||
extern double benchmark_loadwallet();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue