diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-04 21:58:59 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-04 22:33:53 +0300 |
commit | b7c09d442bb6e4ca8d78603a1a508c3bdfcc9082 (patch) | |
tree | 63155a3b0bec8b83fbb745c96e621ac1ca962242 | |
parent | 16d68158012fdcb83d2007680fa0abc7cfd34801 (diff) |
Add Stopwatch
-rw-r--r-- | libkms++util/stopwatch.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libkms++util/stopwatch.h b/libkms++util/stopwatch.h new file mode 100644 index 0000000..9b60fa1 --- /dev/null +++ b/libkms++util/stopwatch.h @@ -0,0 +1,28 @@ +#include <chrono> + +class Stopwatch +{ +public: + void start() + { + m_start = std::chrono::steady_clock::now(); + } + + double elapsed_s() const + { + return std::chrono::duration<double>(std::chrono::steady_clock::now() - m_start).count(); + } + + double elapsed_ms() const + { + return std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - m_start).count(); + } + + double elapsed_us() const + { + return std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - m_start).count(); + } + +private: + std::chrono::steady_clock::time_point m_start; +}; |