diff options
-rw-r--r-- | tests/performance_tests/main.cpp | 221 | ||||
-rw-r--r-- | tests/performance_tests/performance_tests.h | 35 |
2 files changed, 135 insertions, 121 deletions
diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 739c6cc87..ba1640263 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -71,7 +71,9 @@ int main(int argc, char** argv) po::options_description desc_options("Command line options"); const command_line::arg_descriptor<std::string> arg_filter = { "filter", "Regular expression filter for which tests to run" }; - command_line::add_arg(desc_options, arg_filter); + const command_line::arg_descriptor<bool> arg_verbose = { "verbose", "Verbose output", false }; + command_line::add_arg(desc_options, arg_filter, ""); + command_line::add_arg(desc_options, arg_verbose, ""); po::variables_map vm; bool r = command_line::handle_error_helper(desc_options, [&]() @@ -84,118 +86,119 @@ int main(int argc, char** argv) return 1; const std::string filter = tools::glob_to_regex(command_line::get_arg(vm, arg_filter)); + bool verbose = command_line::get_arg(vm, arg_verbose); performance_timer timer; timer.start(); - TEST_PERFORMANCE3(filter, test_construct_tx, 1, 1, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 1, 2, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 1, 10, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 1, 100, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 1, 1000, false); - - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 1, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 2, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 10, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 100, false); - - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 1, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 2, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 10, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 100, false); - - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 1, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 2, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 10, false); - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 100, false); - - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 1, true); - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 2, true); - TEST_PERFORMANCE3(filter, test_construct_tx, 2, 10, true); - - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 1, true); - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 2, true); - TEST_PERFORMANCE3(filter, test_construct_tx, 10, 10, true); - - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 1, true); - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 2, true); - TEST_PERFORMANCE3(filter, test_construct_tx, 100, 10, true); - - TEST_PERFORMANCE2(filter, test_check_tx_signature, 1, false); - TEST_PERFORMANCE2(filter, test_check_tx_signature, 2, false); - TEST_PERFORMANCE2(filter, test_check_tx_signature, 10, false); - TEST_PERFORMANCE2(filter, test_check_tx_signature, 100, false); - - TEST_PERFORMANCE2(filter, test_check_tx_signature, 2, true); - TEST_PERFORMANCE2(filter, test_check_tx_signature, 10, true); - TEST_PERFORMANCE2(filter, test_check_tx_signature, 100, true); - - TEST_PERFORMANCE0(filter, test_is_out_to_acc); - TEST_PERFORMANCE0(filter, test_is_out_to_acc_precomp); - TEST_PERFORMANCE0(filter, test_generate_key_image_helper); - TEST_PERFORMANCE0(filter, test_generate_key_derivation); - TEST_PERFORMANCE0(filter, test_generate_key_image); - TEST_PERFORMANCE0(filter, test_derive_public_key); - TEST_PERFORMANCE0(filter, test_derive_secret_key); - TEST_PERFORMANCE0(filter, test_ge_frombytes_vartime); - TEST_PERFORMANCE0(filter, test_generate_keypair); - TEST_PERFORMANCE0(filter, test_sc_reduce32); - - TEST_PERFORMANCE2(filter, test_wallet2_expand_subaddresses, 50, 200); - - TEST_PERFORMANCE0(filter, test_cn_slow_hash); - TEST_PERFORMANCE1(filter, test_cn_fast_hash, 32); - TEST_PERFORMANCE1(filter, test_cn_fast_hash, 16384); - - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 3, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 5, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 10, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 100, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 3, true); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 5, true); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 10, true); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 100, true); - - TEST_PERFORMANCE2(filter, test_equality, memcmp32, true); - TEST_PERFORMANCE2(filter, test_equality, memcmp32, false); - TEST_PERFORMANCE2(filter, test_equality, verify32, false); - TEST_PERFORMANCE2(filter, test_equality, verify32, false); - - TEST_PERFORMANCE1(filter, test_range_proof, true); - TEST_PERFORMANCE1(filter, test_range_proof, false); - - TEST_PERFORMANCE2(filter, test_bulletproof, true, 1); - TEST_PERFORMANCE2(filter, test_bulletproof, false, 1); - - TEST_PERFORMANCE2(filter, test_bulletproof, true, 2); - TEST_PERFORMANCE2(filter, test_bulletproof, false, 2); - - TEST_PERFORMANCE2(filter, test_bulletproof, true, 15); - TEST_PERFORMANCE2(filter, test_bulletproof, false, 15); - - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 3, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 5, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 10, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 100, false); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 3, true); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 5, true); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 10, true); - TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 100, true); - - TEST_PERFORMANCE1(filter, test_crypto_ops, op_sc_add); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_sc_sub); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_sc_mul); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_ge_add_raw); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_ge_add_p3_p3); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_addKeys); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_scalarmultBase); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_scalarmultKey); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_ge_double_scalarmult_base_vartime); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_ge_double_scalarmult_precomp_vartime); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_ge_double_scalarmult_precomp_vartime2); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_addKeys2); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_addKeys3); - TEST_PERFORMANCE1(filter, test_crypto_ops, op_addKeys3_2); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 1, 1, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 1, 2, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 1, 10, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 1, 100, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 1, 1000, false); + + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 1, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 2, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 10, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 100, false); + + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 1, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 2, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 10, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 100, false); + + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 1, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 2, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 10, false); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 100, false); + + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 1, true); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 2, true); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 2, 10, true); + + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 1, true); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 2, true); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 10, 10, true); + + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 1, true); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 2, true); + TEST_PERFORMANCE3(filter, verbose, test_construct_tx, 100, 10, true); + + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 1, false); + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 2, false); + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 10, false); + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 100, false); + + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 2, true); + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 10, true); + TEST_PERFORMANCE2(filter, verbose, test_check_tx_signature, 100, true); + + TEST_PERFORMANCE0(filter, verbose, test_is_out_to_acc); + TEST_PERFORMANCE0(filter, verbose, test_is_out_to_acc_precomp); + TEST_PERFORMANCE0(filter, verbose, test_generate_key_image_helper); + TEST_PERFORMANCE0(filter, verbose, test_generate_key_derivation); + TEST_PERFORMANCE0(filter, verbose, test_generate_key_image); + TEST_PERFORMANCE0(filter, verbose, test_derive_public_key); + TEST_PERFORMANCE0(filter, verbose, test_derive_secret_key); + TEST_PERFORMANCE0(filter, verbose, test_ge_frombytes_vartime); + TEST_PERFORMANCE0(filter, verbose, test_generate_keypair); + TEST_PERFORMANCE0(filter, verbose, test_sc_reduce32); + + TEST_PERFORMANCE2(filter, verbose, test_wallet2_expand_subaddresses, 50, 200); + + TEST_PERFORMANCE0(filter, verbose, test_cn_slow_hash); + TEST_PERFORMANCE1(filter, verbose, test_cn_fast_hash, 32); + TEST_PERFORMANCE1(filter, verbose, test_cn_fast_hash, 16384); + + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 3, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 5, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 10, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 100, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 3, true); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 5, true); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 10, true); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 100, true); + + TEST_PERFORMANCE2(filter, verbose, test_equality, memcmp32, true); + TEST_PERFORMANCE2(filter, verbose, test_equality, memcmp32, false); + TEST_PERFORMANCE2(filter, verbose, test_equality, verify32, false); + TEST_PERFORMANCE2(filter, verbose, test_equality, verify32, false); + + TEST_PERFORMANCE1(filter, verbose, test_range_proof, true); + TEST_PERFORMANCE1(filter, verbose, test_range_proof, false); + + TEST_PERFORMANCE2(filter, verbose, test_bulletproof, true, 1); + TEST_PERFORMANCE2(filter, verbose, test_bulletproof, false, 1); + + TEST_PERFORMANCE2(filter, verbose, test_bulletproof, true, 2); + TEST_PERFORMANCE2(filter, verbose, test_bulletproof, false, 2); + + TEST_PERFORMANCE2(filter, verbose, test_bulletproof, true, 15); + TEST_PERFORMANCE2(filter, verbose, test_bulletproof, false, 15); + + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 3, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 5, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 10, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 100, false); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 3, true); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 5, true); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 10, true); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 100, true); + + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_sc_add); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_sc_sub); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_sc_mul); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_ge_add_raw); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_ge_add_p3_p3); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_addKeys); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_scalarmultBase); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_scalarmultKey); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_ge_double_scalarmult_base_vartime); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_ge_double_scalarmult_precomp_vartime); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_ge_double_scalarmult_precomp_vartime2); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_addKeys2); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_addKeys3); + TEST_PERFORMANCE1(filter, verbose, test_crypto_ops, op_addKeys3_2); TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_bos_coster, 2); TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_bos_coster, 8); diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h index 29d296571..6f613e0a5 100644 --- a/tests/performance_tests/performance_tests.h +++ b/tests/performance_tests/performance_tests.h @@ -67,8 +67,9 @@ template <typename T> class test_runner { public: - test_runner() + test_runner(bool verbose = true) : m_elapsed(0) + , m_verbose(verbose) { } @@ -81,7 +82,8 @@ public: performance_timer timer; timer.start(); warm_up(); - std::cout << "Warm up: " << timer.elapsed_ms() << " ms" << std::endl; + if (m_verbose) + std::cout << "Warm up: " << timer.elapsed_ms() << " ms" << std::endl; timer.start(); for (size_t i = 0; i < T::loop_count; ++i) @@ -120,21 +122,29 @@ private: private: volatile uint64_t m_warm_up; ///<! This field is intended for preclude compiler optimizations int m_elapsed; + bool m_verbose; }; template <typename T> -void run_test(const std::string &filter, const char* test_name) +void run_test(const std::string &filter, bool verbose, const char* test_name) { boost::smatch match; if (!filter.empty() && !boost::regex_match(std::string(test_name), match, boost::regex(filter))) return; - test_runner<T> runner; + test_runner<T> runner(verbose); if (runner.run()) { - std::cout << test_name << " - OK:\n"; - std::cout << " loop count: " << T::loop_count << '\n'; - std::cout << " elapsed: " << runner.elapsed_time() << " ms\n"; + if (verbose) + { + std::cout << test_name << " - OK:\n"; + std::cout << " loop count: " << T::loop_count << '\n'; + std::cout << " elapsed: " << runner.elapsed_time() << " ms\n"; + } + else + { + std::cout << test_name << " (" << T::loop_count << " calls) - OK:"; + } const char *unit = "ms"; int time_per_call = runner.time_per_call(); if (time_per_call < 30000) { @@ -145,7 +155,7 @@ void run_test(const std::string &filter, const char* test_name) unit = "µs"; #endif } - std::cout << " time per call: " << time_per_call << " " << unit << "/call\n" << std::endl; + std::cout << (verbose ? " time per call: " : " ") << time_per_call << " " << unit << "/call" << (verbose ? "\n" : "") << std::endl; } else { @@ -154,7 +164,8 @@ void run_test(const std::string &filter, const char* test_name) } #define QUOTEME(x) #x -#define TEST_PERFORMANCE0(filter, test_class) run_test< test_class >(filter, QUOTEME(test_class)) -#define TEST_PERFORMANCE1(filter, test_class, a0) run_test< test_class<a0> >(filter, QUOTEME(test_class<a0>)) -#define TEST_PERFORMANCE2(filter, test_class, a0, a1) run_test< test_class<a0, a1> >(filter, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ">") -#define TEST_PERFORMANCE3(filter, test_class, a0, a1, a2) run_test< test_class<a0, a1, a2> >(filter, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ">") +#define TEST_PERFORMANCE0(filter, verbose, test_class) run_test< test_class >(filter, verbose, QUOTEME(test_class)) +#define TEST_PERFORMANCE1(filter, verbose, test_class, a0) run_test< test_class<a0> >(filter, verbose, QUOTEME(test_class<a0>)) +#define TEST_PERFORMANCE2(filter, verbose, test_class, a0, a1) run_test< test_class<a0, a1> >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ">") +#define TEST_PERFORMANCE3(filter, verbose, test_class, a0, a1, a2) run_test< test_class<a0, a1, a2> >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ">") +#define TEST_PERFORMANCE4(filter, verbose, test_class, a0, a1, a2, a3) run_test< test_class<a0, a1, a2, a3> >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ", " QUOTEME(a3) ">") |