Add measures and tests.
[crypto_lab3.git] / src / Utils.cpp
1 #include "Utils.h"
2
3 #include <iostream>
4 using namespace std;
5
6 Timer::Timer() :
7 time(chrono::high_resolution_clock::now())
8 {}
9
10 int Timer::ms() const
11 {
12 return chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - this->time).count();
13 }
14
15 void Timer::reset()
16 {
17 this->time = chrono::high_resolution_clock::now();
18 }
19
20 ostream& operator<<(ostream& os, const Timer& t)
21 {
22 os << t.ms() << " ms";
23 return os;
24 }