stopwatch
This commit is contained in:
1 parent
410d37be99
commit
325db852c4
4 files changed
+36
-33
No files matched your search
@@ -0,0 +1,22 @@
|
||||
#include <chrono>
|
||||
|
||||
class Stopwatch {
|
||||
private:
|
||||
std::chrono::high_resolution_clock::time_point start =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
public:
|
||||
void Restart() {
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
int GetElapsedMS() {
|
||||
auto current = std::chrono::high_resolution_clock::now();
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(current - start).count();
|
||||
}
|
||||
|
||||
double GetElapsedSec() {
|
||||
auto current = std::chrono::high_resolution_clock::now();
|
||||
return std::chrono::duration_cast<
|
||||
std::chrono::duration<double>>(current - start).count();
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user