diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-02-10 19:43:06 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-02-10 22:56:34 +0000 |
commit | 7403e56fb47164cd52d2db9107d82e0fffd9caf6 (patch) | |
tree | 193b076f69be3245be60883e0432ac726ac6ef2c /tests/performance_tests | |
parent | performance_tests: add tests for sc_reduce32 and cn_fast_hash (diff) | |
download | monero-7403e56fb47164cd52d2db9107d82e0fffd9caf6.tar.xz |
performance_tests: report small time per call in microseconds
This is to not report quick operations as 0 milliseconds
Diffstat (limited to 'tests/performance_tests')
-rw-r--r-- | tests/performance_tests/performance_tests.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h index 77707148b..88e8b592c 100644 --- a/tests/performance_tests/performance_tests.h +++ b/tests/performance_tests/performance_tests.h @@ -95,10 +95,10 @@ public: int elapsed_time() const { return m_elapsed; } - int time_per_call() const + int time_per_call(int scale = 1) const { static_assert(0 < T::loop_count, "T::loop_count must be greater than 0"); - return m_elapsed / T::loop_count; + return m_elapsed * scale / T::loop_count; } private: @@ -130,7 +130,17 @@ void run_test(const char* test_name) std::cout << test_name << " - OK:\n"; std::cout << " loop count: " << T::loop_count << '\n'; std::cout << " elapsed: " << runner.elapsed_time() << " ms\n"; - std::cout << " time per call: " << runner.time_per_call() << " ms/call\n" << std::endl; + const char *unit = "ms"; + int time_per_call = runner.time_per_call(); + if (time_per_call < 30000) { + time_per_call = runner.time_per_call(1000); +#ifdef _WIN32 + unit = "\xb5s"; +#else + unit = "µs"; +#endif + } + std::cout << " time per call: " << time_per_call << " " << unit << "/call\n" << std::endl; } else { |