Skip to content
Snippets Groups Projects
Commit fbd169dd authored by Ian Bell's avatar Ian Bell
Browse files

Move Timer class into types

parent 13216020
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include <valarray> #include <valarray>
#include <set> #include <set>
#include <chrono>
// Registration of types that are considered to be containers // Registration of types that are considered to be containers
// See https://stackoverflow.com/a/12045843 // See https://stackoverflow.com/a/12045843
...@@ -57,3 +58,15 @@ auto all_same_length = [](const nlohmann::json& j, const std::vector<std::string ...@@ -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()); } for (auto k : ks) { lengths.insert(j[k].size()); }
return lengths.size() == 1; 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment