0

如何查看我的申请的评估处理时间。例如需要做多少次 A, B, C, A+C, B+C, ...

4

3 回答 3

0

如果你使用 linux。命令“时间”可以帮助您:

$time ./a.out 

real    0m0.137s
user    0m0.001s
sys     0m0.001s
于 2013-09-18T15:47:16.263 回答
0

使用 QueryPerformanceCounter()。

LARGE_INTEGER s, e, f;

QueryPerformanceFrequency( &f );
QueryPerformanceCounter( &s );

// TO DO: add your code here

QueryPerformanceCounter( &e );


const __int64 durationMilliseconds = ( e.QuadPart - s.QuadPart ) * 1000 / f.QuadPart;
于 2013-09-18T19:20:13.103 回答
0
  1. 您可以使用gettimeofday()并使用该timersub()功能来获得差异。

  2. 您可以使用clock()并减去两次。记得 #include 。

- 参考自:

如何减去两个 gettimeofday 实例?

http://www.cplusplus.com/forum/unices/50561/

C++ 中最好、最准确的计时器是什么?

编辑:另一个选择是chrono i/o。提供非常高的精度。 http://howardhinnant.github.io/duration_io/chrono_io.html

于 2013-09-18T15:28:51.683 回答