/****************************************************************************** * Filename: HighResTimer.cpp * Date: 12/06/2010 * Mod. Date: 03/21/2018 * Author: Joseph R. Pollack * Purpose: A high resolution timer suitable for profiling code. This new * version has stripped out the game specific functionality and * does not include windows.h in the header. ******************************************************************************/ #include "HighResTimer.h" using std::chrono::high_resolution_clock; using std::chrono::duration; using std::chrono::duration_cast; using std::chrono::microseconds; namespace Lunarium { // Starts or re-starts the timer. void HighResTimer::Reset() { mStartTime = high_resolution_clock::now(); } // Returns the amount of time in microseconds since the last Reset() call. int64_t HighResTimer::GetElapsedMicros() { auto endTime = high_resolution_clock::now(); auto micros = duration_cast(endTime - mStartTime); return micros.count(); } double HighResTimer::GetElapsedSeconds() { auto endTime = high_resolution_clock::now(); duration s = endTime - mStartTime; return s.count(); } }