2021-07-13 16:36:41 -04:00
|
|
|
/*
|
|
|
|
Stopwatch.cpp
|
|
|
|
Simple class designed to provide timing info on parts of the process.
|
|
|
|
Only for use in development.
|
|
|
|
|
|
|
|
Written by G.W. McCann Oct. 2020
|
|
|
|
*/
|
2021-12-18 15:40:53 -05:00
|
|
|
#include "EventBuilder.h"
|
2021-07-13 16:36:41 -04:00
|
|
|
#include "Stopwatch.h"
|
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
namespace EventBuilder {
|
2021-07-13 16:36:41 -04:00
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
Stopwatch::Stopwatch()
|
|
|
|
{
|
|
|
|
start_time = Clock::now();
|
|
|
|
stop_time = start_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stopwatch::~Stopwatch() {}
|
|
|
|
|
|
|
|
void Stopwatch::Start()
|
|
|
|
{
|
|
|
|
start_time = Clock::now();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stopwatch::Stop()
|
|
|
|
{
|
|
|
|
stop_time = Clock::now();
|
|
|
|
}
|
|
|
|
|
|
|
|
double Stopwatch::GetElapsedSeconds()
|
|
|
|
{
|
|
|
|
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count();
|
|
|
|
}
|
|
|
|
|
|
|
|
double Stopwatch::GetElapsedMilliseconds()
|
|
|
|
{
|
|
|
|
return std::chrono::duration_cast<std::chrono::duration<double>>(stop_time-start_time).count()*1000.0;
|
|
|
|
}
|
2021-07-13 16:36:41 -04:00
|
|
|
|
|
|
|
}
|