"프로그램 실행 시간 측정"의 두 판 사이의 차이
jjuiddong
(새 문서: * http://dj0155.tistory.com/entry/%EC%BD%94%EB%93%9C-%EC%8B%A4%ED%96%89-%EC%8B%9C%EA%B0%84-%EC%B8%A1%EC%A0%95) |
|||
1번째 줄: | 1번째 줄: | ||
* http://dj0155.tistory.com/entry/%EC%BD%94%EB%93%9C-%EC%8B%A4%ED%96%89-%EC%8B%9C%EA%B0%84-%EC%B8%A1%EC%A0%95 | * http://dj0155.tistory.com/entry/%EC%BD%94%EB%93%9C-%EC%8B%A4%ED%96%89-%EC%8B%9C%EA%B0%84-%EC%B8%A1%EC%A0%95 | ||
+ | |||
+ | #include <windows.h> | ||
+ | #include <stdio.h> | ||
+ | |||
+ | #define CHECK_TIME_START __int64 freq, start, end; if (QueryPerformanceFrequency((_LARGE_INTEGER*)&freq)) {QueryPerformanceCounter((_LARGE_INTEGER*)&start); | ||
+ | |||
+ | // a는 float type milli second이고 b가 FALSE일때는 에러입니다 | ||
+ | #define CHECK_TIME_END(a,b) QueryPerformanceCounter((_LARGE_INTEGER*)&end); a=(float)((double)(end - start)/freq*1000); b=TRUE; } else b=FALSE; | ||
+ | |||
+ | float Time; | ||
+ | bool err; | ||
+ | CHECK_TIME_START; | ||
+ | |||
+ | // 측정할 코드 | ||
+ | |||
+ | CHECK_TIME_END(Time, err); |
2013년 4월 10일 (수) 16:22 기준 최신판
#include <windows.h> #include <stdio.h> #define CHECK_TIME_START __int64 freq, start, end; if (QueryPerformanceFrequency((_LARGE_INTEGER*)&freq)) {QueryPerformanceCounter((_LARGE_INTEGER*)&start); // a는 float type milli second이고 b가 FALSE일때는 에러입니다 #define CHECK_TIME_END(a,b) QueryPerformanceCounter((_LARGE_INTEGER*)&end); a=(float)((double)(end - start)/freq*1000); b=TRUE; } else b=FALSE; float Time; bool err; CHECK_TIME_START; // 측정할 코드 CHECK_TIME_END(Time, err);