This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 我想测试一段C++程序的运行速度,有什么函数可以得到当前时间?或在windows(dos)/Unix下分别有什么命令可以测试程序运行的时间?
-smallwhale(喝不了咖啡);
2003-2-17
(#1046319@0)
-
GetSystemTime
-lusi(丑小鸭);
2003-2-17
(#1046349@0)
-
能详细点吗?这是函数还是命令名?
-smallwhale(喝不了咖啡);
2003-2-17
(#1046407@0)
-
there might be some other functions which can do the work, but the following is the one I prefer.SYSTEMTIME startTime;
GetSystemTime(&starTime);
..... // your code which you want to time
SYSTEMTIME endTime;
GetSystemTime(&endTime);
double elapsed = (endTime.wSecond + endTime.wMilliseconds / 1.0e3) - (startTime.wSecond + startTime.wMilliseconds / 1.0e3); // time in seconds
-lusi(丑小鸭);
2003-2-17
{289}
(#1046417@0)
-
谢谢,在哪个library里?
-smallwhale(喝不了咖啡);
2003-2-17
(#1046467@0)
-
faint. do you not have MSDN? "Declared in Winbase.h; include Windows.h."
-lusi(丑小鸭);
2003-2-17
(#1046469@0)
-
因为我要运行在不同操作系统下,所以我只用standard C/C++里的东西,所以不熟悉windows的库。不过测试无所谓。Anyway谢谢
-smallwhale(喝不了咖啡);
2003-2-17
(#1046486@0)
-
clock() might be the one of Standard C.
-lusi(丑小鸭);
2003-2-17
(#1046498@0)
-
linux下面命令, #times <函数>times Print the accumulated user and system times for the
shell and for processes run from the shell. The
return status is 0.
-gettext(gettext);
2003-2-17
{160}
(#1047005@0)
-
GetTickCount(), return in ms
-enchanted(密码);
2003-2-18
(#1047969@0)