微微一笑倾城土豆网7:怎么测试程序运行时间?

来源:百度文库 编辑:高校问答 时间:2024/04/30 18:26:00
测试一段代码运行的时间。
用vc++编程,精确到毫秒。time里面有没有可以的。
看别人用的是这个,好像挺简单的。
大概是获得运行前后的时间,相减。
该用什么函数,什么类型?
谢谢了

GetTickCount
The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function.

DWORD GetTickCount(VOID);
Parameters
This function has no parameters.

Return Values
The return value is the number of milliseconds that have elapsed since the system was started.

精度大约在10ms