mirror of
https://github.com/sesps/SPS_SABRE_EventBuilder.git
synced 2024-09-21 14:47:25 -04:00
41 lines
779 B
C++
41 lines
779 B
C++
/*
|
|
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
|
|
*/
|
|
#include "EventBuilder.h"
|
|
#include "Stopwatch.h"
|
|
|
|
namespace EventBuilder {
|
|
|
|
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;
|
|
}
|
|
|
|
} |