Profile work validation (#2322)
* Profile work validation * Add CLI debug_proifile_validation to profile work validation * Replace previous verify command
This commit is contained in:
parent
6a8c2fa726
commit
335f783cda
1 changed files with 19 additions and 20 deletions
|
|
@ -117,8 +117,8 @@ int main (int argc, char * const * argv)
|
|||
("debug_account_count", "Display the number of accounts")
|
||||
("debug_mass_activity", "Generates fake debug activity")
|
||||
("debug_profile_generate", "Profile work generation")
|
||||
("debug_profile_validate", "Profile work validation")
|
||||
("debug_opencl", "OpenCL work generation")
|
||||
("debug_profile_verify", "Profile work verification")
|
||||
("debug_profile_kdf", "Profile kdf function")
|
||||
("debug_output_last_backtrace_dump", "Displays the contents of the latest backtrace in the event of a nano_node crash")
|
||||
("debug_sys_logging", "Test the system logger")
|
||||
|
|
@ -358,6 +358,24 @@ int main (int argc, char * const * argv)
|
|||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast<std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_profile_validate"))
|
||||
{
|
||||
uint64_t difficulty{ nano::network_constants::publish_full_threshold };
|
||||
std::cerr << "Starting validation profile" << std::endl;
|
||||
auto start (std::chrono::steady_clock::now ());
|
||||
bool valid{ false };
|
||||
nano::block_hash hash{ 0 };
|
||||
uint64_t count{ 10000000U }; // 10M
|
||||
for (uint64_t i (0); i < count; ++i)
|
||||
{
|
||||
valid = nano::work_value (hash, i) > difficulty;
|
||||
}
|
||||
std::ostringstream oss (valid ? "true" : "false"); // IO forces compiler to not dismiss the variable
|
||||
auto total_time (std::chrono::duration_cast<std::chrono::nanoseconds> (std::chrono::steady_clock::now () - start).count ());
|
||||
uint64_t average (total_time / count);
|
||||
std::cout << "Average validation time: " << std::to_string (average) << " ns (" << std::to_string (static_cast<unsigned> (count * 1e9 / total_time)) << " validations/s)" << std::endl;
|
||||
return average;
|
||||
}
|
||||
else if (vm.count ("debug_opencl"))
|
||||
{
|
||||
nano::network_constants network_constants;
|
||||
|
|
@ -468,25 +486,6 @@ int main (int argc, char * const * argv)
|
|||
result = -1;
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_profile_verify"))
|
||||
{
|
||||
nano::work_pool work (std::numeric_limits<unsigned>::max ());
|
||||
nano::change_block block (0, 0, nano::keypair ().prv, 0, 0);
|
||||
std::cerr << "Starting verification profiling\n";
|
||||
while (true)
|
||||
{
|
||||
block.hashables.previous.qwords[0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
for (uint64_t t (0); t < 1000000; ++t)
|
||||
{
|
||||
block.hashables.previous.qwords[0] += 1;
|
||||
block.block_work_set (t);
|
||||
nano::work_validate (block);
|
||||
}
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast<std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_output_last_backtrace_dump"))
|
||||
{
|
||||
if (boost::filesystem::exists ("nano_node_backtrace.dump"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue