From fbd169dd7f636bca950a8ef3922d46eb0776d743 Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Fri, 18 Jun 2021 15:14:43 -0400
Subject: [PATCH] Move Timer class into types

---
 include/teqp/types.hpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/teqp/types.hpp b/include/teqp/types.hpp
index a9644a9..e84f21d 100644
--- a/include/teqp/types.hpp
+++ b/include/teqp/types.hpp
@@ -5,6 +5,7 @@
 #include <vector>
 #include <valarray>
 #include <set>
+#include <chrono>
 
 // Registration of types that are considered to be containers
 // See https://stackoverflow.com/a/12045843
@@ -57,3 +58,15 @@ auto all_same_length = [](const nlohmann::json& j, const std::vector<std::string
     for (auto k : ks) { lengths.insert(j[k].size()); }
     return lengths.size() == 1;
 };
+
+class Timer {
+private:
+    int N;
+    decltype(std::chrono::steady_clock::now()) tic;
+public:
+    Timer(int N) : N(N), tic(std::chrono::steady_clock::now()) {}
+    ~Timer() {
+        auto elap = std::chrono::duration<double>(std::chrono::steady_clock::now() - tic).count();
+        std::cout << elap / N * 1e6 << " us/call" << std::endl;
+    }
+};
\ No newline at end of file
-- 
GitLab