04-08 23:03
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

[C/C++] Performance 측정 본문

Programming/C&C++

[C/C++] Performance 측정

cinema4dr12 2015. 9. 26. 20:45

이번 글에서는 특정 procedure에 성능 측정 지표로서 계산 시간을 측정하는 방법에 대하여 알아보도록 하겠다.


[방법 1.]

1
2
3
4
5
6
7
8
9
10
11
#include <time.h>
 
clock_t start, end;
double elapsed;
start = clock();
  
/* Your code    */
  
end = clock();
elapsed = ( (double)( end - start ) ) / CLOCKS_PER_SEC;
std::cout << elapsed;


[방법 2.]

1
2
3
4
double t = (double)getTickCount();
// do something ...
t = ((double)getTickCount() - t)/getTickFrequency();
std::cout << "Times passed in seconds: " << t << std::endl;


Comments