You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

#pragma once
#include <windows.h>
namespace CELL
{
class CELLTimestamp
{
public:
CELLTimestamp()
{
QueryPerformanceFrequency(&_frequency);
QueryPerformanceCounter(&_startCount);
}
~CELLTimestamp()
{}
void update()
{
QueryPerformanceCounter(&_startCount);
}
/**
* »ñÈ¡µ±Ç°Ãë
*/
double getElapsedSecond()
{
return getElapsedTimeInMicroSec() * 0.000001;
}
/**
* »ñÈ¡ºÁÃë
*/
double getElapsedTimeInMilliSec()
{
return this->getElapsedTimeInMicroSec() * 0.001;
}
/**
* »ñȡ΢Ãî
*/
double getElapsedTimeInMicroSec()
{
LARGE_INTEGER endCount;
QueryPerformanceCounter(&endCount);
double startTimeInMicroSec = _startCount.QuadPart * (1000000.0 / _frequency.QuadPart);
double endTimeInMicroSec = endCount.QuadPart * (1000000.0 / _frequency.QuadPart);
return endTimeInMicroSec - startTimeInMicroSec;
}
protected:
LARGE_INTEGER _frequency;
LARGE_INTEGER _startCount;
};
}