s***1 发帖数: 49 | 1 我的程序里面有3条指令,现在我想知道这3条指令一共需要多少时间执行(
milliseconds). 我google到的一个程序:
Begin = clock() * CLK_TCK; //start the timer
//中间的指令
End = clock() * CLK_TCK;
elapTicks = End - Begin; //the number of ticks from Begin to End
elapMilli = elapTicks/1000;
elapMilli = 总共时间。 |
O*******d 发帖数: 20343 | 2 clock_t Begin = clock() ; //start the timer
//中间的指令
clock_t End = clock() ;
clock_t elapTicks = End - Begin; //the number of ticks from Begin to End
float elapMilli = (float)elapTicks/ (float) CLOCKS_PER_SEC * 1000.0f;
elapMilli = 总共时间。
【在 s***1 的大作中提到】 : 我的程序里面有3条指令,现在我想知道这3条指令一共需要多少时间执行( : milliseconds). 我google到的一个程序: : Begin = clock() * CLK_TCK; //start the timer : //中间的指令 : End = clock() * CLK_TCK; : elapTicks = End - Begin; //the number of ticks from Begin to End : elapMilli = elapTicks/1000; : elapMilli = 总共时间。
|
O*******d 发帖数: 20343 | 3 clock() returns process execution time, not the real time. If you have
another program running extensively at the same time you are running this
program, the elapMilli is much smaller than the actual time. |