stopwatch

This commit is contained in:
rektdie committed 2025-03-10 22:26:43 +01:00
1 parent 410d37be99
commit 325db852c4
4 files changed
+36 -33

No files matched your search

+22
View File
@@ -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();
}
};