You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/utils/HighResTimer.h

43 lines
1.1 KiB
C++

/******************************************************************************
* Filename: HighResTimer.h
* 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.
******************************************************************************/
// TODO: Rewrite class with c++11 standard code: https://stackoverflow.com/questions/22387586/measuring-execution-time-of-a-function-in-c
#ifndef HIGH_RES_TIMER_H_
#define HIGH_RES_TIMER_H_
#include <stdint.h>
#include <chrono>
namespace Lunarium
{
class HighResTimer
{
public:
// Starts or re starts the timer.
void Reset();
// Returns the amount of time in microseconds since the last Reset() call.
int64_t GetElapsedMicros();
// Returns the elapsed time in terms of seconds
double GetElapsedSeconds();
private:
std::chrono::time_point<std::chrono::high_resolution_clock> mStartTime;
};
}
#endif // HIGH_RES_TIMER_H_