1
0
Fork 0

Adding Spectre/System/Stopwatch

This commit is contained in:
Henrik Hautakoski 2020-12-14 19:09:17 +01:00
parent 919aa7740a
commit f62373dcbc
3 changed files with 54 additions and 1 deletions

View file

@ -0,0 +1,25 @@
#include <Spectre/System/Stopwatch.h>
#include <Spectre/System/System.h>
namespace sp {
Stopwatch::Stopwatch()
{
m_start = Time::milliseconds(system::getMilliseconds());
}
Time Stopwatch::restart()
{
Time now = Time::milliseconds(system::getMilliseconds());
Time elapsed = now - m_start;
m_start = now;
return elapsed;
}
Time Stopwatch::elapsed() const
{
return Time::milliseconds(system::getMilliseconds()) - m_start;
}
} // namespace sp