TICK 与 CLOCK CYCLE 的区别
来源:互联网 发布:东方中原电子白板软件 编辑:程序博客网 时间:2024/05/22 08:05
… …
BeginScene();
… …
// Start profiling
LARGE_INTEGER start, stop, freq;
QueryPerformanceCounter(&start);
SetTexture(...);
DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
QueryPerformanceCounter(&stop);
stop.QuadPart -= start.QuadPart;
QueryPerformanceFrequency(&freq);
// Stop profiling
… …
EndScene();
Present();
Example 2: Custom Profiling Implementation with QPC
start and stop are two large integers that will hold the start and stop values returned by the high-performance timer. Notice that QueryPerformanceCounter(&start) is called just before IDirect3DDevice9::SetTexture and QueryPerformanceCounter(&stop) is called just after IDirect3DDevice9::DrawPrimitive. After getting the stop value, QueryPerformanceFrequency is called to return freq, which is the frequency of the high-resolution timer. In this hypothetical example, suppose you get the following results for start, stop, and freq:
Local Variable
Number of Ticks
start
1792998845094
stop
1792998845102
freq
3579545
You could convert these values to the number of cycles it takes to execute the API calls like this:
# ticks = (stop - start) = 1792998845102 - 1792998845094 = 8 ticks
# cycles = CPU speed * number of ticks / QPF
# 4568 = 2 GHz * 8 / 3,579,545
In other words, it takes about 4568 clock cycles to process IDirect3DDevice9::SetTexture and IDirect3DDevice9::DrawPrimitive on this 2 GHz machine. You could convert these values to the actual time it took to execute all the calls like this:
(stop - start)/ freq = elapsed time
8 ticks / 3,579,545 = 2.2E-6 seconds or between 2 and 3 microseconds.
需要清楚:
TICK,滴答,计算机的计时器的单位。
Hz,CLOCK CYCLE,CPU的时钟周期的单位。
QueryPerformanceFrequency()取出的TICK数是1秒钟内计算机计时器的滴答数。这个数值通常来自8253计时芯片。
2 GHz是1秒钟内CPU的时钟周期数。显然这个数据来自CPU。
在一个TICK里,计算机通过CPU要做(开、关开关)许多次。所以通常一秒钟时间里,CPU的CLOCK CYCLE都会比TICK大很多,这样在一个TICK里才可以让CPU跑很多个CLOCK CYCLE,完成很多操作。
- TICK 与 CLOCK CYCLE 的区别
- clock tick rate异常
- pygame clock.tick
- clock()与GetTickCount()的区别与作用
- Timer 控件中的Elapsed事件与tick事件的区别
- clock()与time()区别
- 时钟滴答(clock tick)
- linux的HZ, Tick, xtime, Jiffies, RTC && mdelay() 与msleep()的区别
- c语言time与clock区别
- HZ、tick与jiffies
- Tick与GraphTask
- C#中tick 与秒的对应关系
- clock realtime 与 clock monotonic
- clock()与clock_gettime()的简单比较
- tick
- TICK
- clock(), sleep(), Sleep()在windows和Linux的区别
- clock()、time()、clock_gettime()和gettimeofday()函数的用法和区别
- 高效程序猿之(二)VS2010优秀插件
- 某个数字出现的次数
- 自己动手学TCP/IP--TCP连接三次握手
- 博弈题集
- Android学习笔记(五)常用控件中
- TICK 与 CLOCK CYCLE 的区别
- 一路走来
- Argus (P2051)
- 连字符,double pound
- Android学习笔记(五)常用控件下
- 关于SSH整合使用MyEclipse自动导入包导致包冲突问题(cglib asm)
- 联机
- VC获取屏幕上任意点位置的颜色
- Android学习笔记(五)常用控件下