diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-02-12 23:23:17 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-02-12 23:23:17 +0200 |
commit | e6c29eb5fca83ca5748b8c61e004677623ab0ffb (patch) | |
tree | 2c41c8b82271da52f593667d194280012468f4b5 /tests/performance_tests/performance_tests.h | |
parent | Merge pull request #1700 (diff) | |
parent | performance_tests: report small time per call in microseconds (diff) | |
download | monero-e6c29eb5fca83ca5748b8c61e004677623ab0ffb.tar.xz |
Merge pull request #1706
7403e56f performance_tests: report small time per call in microseconds (moneromooo-monero)
cadada2d performance_tests: add tests for sc_reduce32 and cn_fast_hash (moneromooo-monero)
962c72b6 performance_tests: initialize logging at startup (moneromooo-monero)
Diffstat (limited to 'tests/performance_tests/performance_tests.h')
-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 { |