summaryrefslogtreecommitdiff
path: root/kms++util/stopwatch.h
diff options
context:
space:
mode:
Diffstat (limited to 'kms++util/stopwatch.h')
-rw-r--r--kms++util/stopwatch.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/kms++util/stopwatch.h b/kms++util/stopwatch.h
new file mode 100644
index 0000000..9b60fa1
--- /dev/null
+++ b/kms++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;
+};