From b7c09d442bb6e4ca8d78603a1a508c3bdfcc9082 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 4 Jun 2016 21:58:59 +0300 Subject: Add Stopwatch --- libkms++util/stopwatch.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 libkms++util/stopwatch.h (limited to 'libkms++util') 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 + +class Stopwatch +{ +public: + void start() + { + m_start = std::chrono::steady_clock::now(); + } + + double elapsed_s() const + { + return std::chrono::duration(std::chrono::steady_clock::now() - m_start).count(); + } + + double elapsed_ms() const + { + return std::chrono::duration(std::chrono::steady_clock::now() - m_start).count(); + } + + double elapsed_us() const + { + return std::chrono::duration(std::chrono::steady_clock::now() - m_start).count(); + } + +private: + std::chrono::steady_clock::time_point m_start; +}; -- cgit v1.2.3