得到每帧的渲染耗时

原创 2007年10月07日 18:59:00

Getting the Time for Each Frame

To accurately time your animations, you need to call the QueryPerformanceCounter function
twice within the game loop: once before you start a drawing, and once after all drawing
has been completed. Both values returned contain the number of counts from the system
at the time the function was called. Because the performance counter has such a high resolution,
both of these values should be unique. You can use the difference between these
two values to determine the number of counts that has passed between the calls.
For example, you could write the following code:
LARGE_INTEGER timeStart;
LARGE_INTEGER timeEnd;
QueryPerformanceCounter(&timeStart);
Render( );
QueryPerformanceCounter(&timeEnd);
LARGE_INTEGER numCounts = ( timeEnd.QuadPart – timeStart.QuadPart )

Now that you’ve updated the sprite code, you have to add in the timer code. The timer
code requires three new global variables:

LARGE_INTEGER timeStart; // holds the starting count
LARGE_INTEGER timeEnd; // holds the ending count
LARGE_INTEGER timerFreq; // holds the frequency of the counter

Next, you need to make a call to QueryPerformanceFrequency to get the frequency of the
counter. You should call this function right before the main message loop:

QueryPerformanceFrequency(&timerFreq);

Finally, you need to add the calls around the Render function to QueryPerformanceCounter.
The first one should go right before the call to Render.

QueryPerformanceCounter(&timeStart);

The second call should go after the call to Render.

QueryPerformanceCounter(&timeEnd);

Immediately following the last QueryPerformanceCounter function, you must determine the
new animation rate.

anim_rate = ( (float)timeEnd.QuadPart - (float)timeStart.QuadPart ) /
timerFreq.QuadPart; 

版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

ffmpeg中将每帧视频图像保存为图片的方法

ffmpeg初识

yolov2-cpu检测90ms每帧之tinier模型(3.5M)应用

众所周知,yolov2是个很好的深度学习框架,是检测算法的得力助手。但是yolov2在windows下cpu的测试速度不尽如人意,原作者给出的模型有多种,如tiny-yolo,以及full-yolo。...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

用Mathematica从GIF文件中导入每帧的DisplayDurations

http://mathematica.stackexchange.com/questions/5361/when-importing-gif-animation-how-to-find-the-cor...

seed-dvs6467 encodedecode实例 采集的图像质量很差,只有隔行显示,而且每帧图像不断的往下移动?

seed-dvs6467 encodedecode

Unity3D学习笔记(4)——获取单帧中函数耗时

Unity3D学习笔记(4)参考链接1 参考链接2CheckFunctionTimeInSingleFrame.csnamespace Assets.Scripts { using Unit...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)