diff options
author | Jack Lloyd <[email protected]> | 2018-12-23 14:26:53 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-23 14:26:53 -0500 |
commit | dd49d5da18b4551285fb8f4a5a3a60d7c6ca1eb2 (patch) | |
tree | 117e491c4f9a0225b336477308118d73e3d74b1f /src/lib | |
parent | f10db2ae3d361132202e8e31376374d0d280482a (diff) |
De-inline more of Timer
No reason for these to be inlined
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/utils/timer.cpp | 37 | ||||
-rw-r--r-- | src/lib/utils/timer.h | 41 |
2 files changed, 37 insertions, 41 deletions
diff --git a/src/lib/utils/timer.cpp b/src/lib/utils/timer.cpp index 634cd83f5..5196397b9 100644 --- a/src/lib/utils/timer.cpp +++ b/src/lib/utils/timer.cpp @@ -11,24 +11,31 @@ namespace Botan { +void Timer::start() + { + stop(); + m_timer_start = OS::get_system_timestamp_ns(); + m_cpu_cycles_start = OS::get_processor_timestamp(); + } + void Timer::stop() { if(m_timer_start) { if(m_cpu_cycles_start != 0) { - uint64_t cycles_taken = Timer::get_cpu_cycle_counter() - m_cpu_cycles_start; + const uint64_t cycles_taken = OS::get_processor_timestamp() - m_cpu_cycles_start; if(cycles_taken > 0) { m_cpu_cycles_used += static_cast<size_t>(cycles_taken * m_clock_cycle_ratio); } } - const uint64_t now = Timer::get_system_timestamp_ns(); + const uint64_t now = OS::get_system_timestamp_ns(); if(now > m_timer_start) { - uint64_t dur = now - m_timer_start; + const uint64_t dur = now - m_timer_start; m_time_used += dur; @@ -48,6 +55,30 @@ void Timer::stop() } } +bool Timer::operator<(const Timer& other) const + { + if(this->doing() != other.doing()) + return (this->doing() < other.doing()); + + return (this->get_name() < other.get_name()); + } + +std::string Timer::to_string() const + { + if(m_custom_msg.size() > 0) + { + return m_custom_msg; + } + else if(this->buf_size() == 0) + { + return result_string_ops(); + } + else + { + return result_string_bps(); + } + } + std::string Timer::result_string_bps() const { const size_t MiB = 1024 * 1024; diff --git a/src/lib/utils/timer.h b/src/lib/utils/timer.h index 86a17b462..6be6c333a 100644 --- a/src/lib/utils/timer.h +++ b/src/lib/utils/timer.h @@ -38,22 +38,7 @@ class BOTAN_TEST_API Timer final Timer(const Timer& other) = default; - static uint64_t get_system_timestamp_ns() - { - return Botan::OS::get_system_timestamp_ns(); - } - - static uint64_t get_cpu_cycle_counter() - { - return Botan::OS::get_processor_timestamp(); - } - - void start() - { - stop(); - m_timer_start = Timer::get_system_timestamp_ns(); - m_cpu_cycles_start = Timer::get_cpu_cycle_counter(); - } + void start(); void stop(); @@ -167,29 +152,9 @@ class BOTAN_TEST_API Timer final m_custom_msg = s; } - bool operator<(const Timer& other) const - { - if(this->doing() != other.doing()) - return (this->doing() < other.doing()); + bool operator<(const Timer& other) const; - return (this->get_name() < other.get_name()); - } - - std::string to_string() const - { - if(m_custom_msg.size() > 0) - { - return m_custom_msg; - } - else if(this->buf_size() == 0) - { - return result_string_ops(); - } - else - { - return result_string_bps(); - } - } + std::string to_string() const; private: std::string result_string_bps() const; |