2022-02-24 22:48:39 -05:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "EventTimer.hpp"
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
using namespace std::string_literals;
|
|
|
|
|
//=========================================================
|
|
|
|
|
EventTimer::EventTimer() {
|
|
|
|
|
_now = std::chrono::high_resolution_clock::now();
|
|
|
|
|
}
|
|
|
|
|
//=========================================================
|
|
|
|
|
|
2022-02-25 09:44:11 -05:00
|
|
|
auto EventTimer::elapsed(bool reset) -> long long {
|
2022-02-24 22:48:39 -05:00
|
|
|
auto delta =std::chrono::high_resolution_clock::now()-_now ;
|
2022-02-25 09:44:11 -05:00
|
|
|
if (reset){
|
|
|
|
|
_now =std::chrono::high_resolution_clock::now();
|
|
|
|
|
}
|
2022-02-24 22:48:39 -05:00
|
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>(delta).count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=========================================================
|
2022-02-25 09:44:11 -05:00
|
|
|
auto EventTimer::output(const std::string &label = "Delta from last call",bool reset)->void {
|
|
|
|
|
std::cout <<label <<" - "s <<elapsed(reset)<<"(ms)\n"s;
|
2022-02-24 22:48:39 -05:00
|
|
|
}
|