private long mFrameCount = 0;
private long mLastFrameTime = 0;
static long mLastFps = 0;//显示的FPS值
private void UpdateTick()
{
if (true)
{
mFrameCount++;
long nCurTime = TickToMilliSec(System.DateTime.Now.Ticks);
if (mLastFrameTime == 0)
{
mLastFrameTime = TickToMilliSec(System.DateTime.Now.Ticks);
}
if ((nCurTime - mLastFrameTime) >= 1000)
{
long fps = (long)(mFrameCount * 1.0f / ((nCurTime - mLastFrameTime) / 1000.0f));
mLastFps = fps;
mFrameCount = 0;
mLastFrameTime = nCurTime;
}
}
}
private static long TickToMilliSec(long tick)
{
return tick / (10 * 1000);
}