diff options
Diffstat (limited to 'DCP/utility.h')
-rw-r--r-- | DCP/utility.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/DCP/utility.h b/DCP/utility.h new file mode 100644 index 0000000..55cc100 --- /dev/null +++ b/DCP/utility.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef UTILITY_H | ||
2 | #define UTILITY_H | ||
3 | |||
4 | #include <iostream> | ||
5 | #include <chrono> | ||
6 | |||
7 | class TicToc | ||
8 | { | ||
9 | private: | ||
10 | typedef std::chrono::high_resolution_clock clock; | ||
11 | typedef std::chrono::microseconds res; | ||
12 | clock::time_point t1, t2; | ||
13 | |||
14 | public: | ||
15 | void tic() | ||
16 | { | ||
17 | t1 = clock::now(); | ||
18 | } | ||
19 | |||
20 | void toc() | ||
21 | { | ||
22 | t2 = clock::now(); | ||
23 | std::cout << "Elapsed time: " | ||
24 | << std::chrono::duration_cast<res>(t2 - t1).count() / 1e6 | ||
25 | << " seconds." << std::endl; | ||
26 | } | ||
27 | }; | ||
28 | |||
29 | #endif \ No newline at end of file | ||