This comment is reply for 892 ココサブ: http://seclan.dll.jp...(実行時間の測定). Go to thread root.
TGBT #1025(2007/07/17 06:55 GMT) [ C ] Rating1/1=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#include <stdio.h> #include <time.h> #include <sys/types.h> #ifdef _WIN32 #include <windows.h> // LARGE_INTEGERに必要 #endif #ifdef _LINUX #include <sys/time.h> // timezoneに必要 #endif #ifdef _WIN32 #define profile(FUNC, ...) \ {\ LARGE_INTEGER liFreq, liBegin, liEnd;\ double dSec;\ QueryPerformanceFrequency(&liFreq);\ QueryPerformanceCounter(&liBegin);\ FUNC(__VA_ARGS__);\ QueryPerformanceCounter(&liEnd);\ dSec = (double)(liEnd.QuadPart - liBegin.QuadPart)/(double)liFreq.QuadPart;\ printf("%f sec\n", dSec);\ } #endif #ifdef _LINUX #define profile(FUNC, ...) \ {\ struct timeval tBegin, tEnd;\ struct timezone tz;\ double dSec;\ double dBegin, dEnd;\ gettimeofday(&tBegin, &tz);\ FUNC(__VA_ARGS__);\ gettimeofday(&tEnd, &tz);\ dBegin = tBegin.tv_sec + (double)tBegin.tv_usec*1.0e-6;\ dEnd = tEnd.tv_sec + (double)tEnd.tv_usec*1.0e-6;\ dSec = dEnd - dBegin;\ printf("%f sec\n", dSec);\ } #endif int main() { profile(printf, "%s:%d\n", "hoge", 10); profile(puts, "abcdef"); return 0; }
Rating1/1=1.00-0+
[ reply ]
TGBT
#1025()
[
C
]
Rating1/1=1.00
Rating1/1=1.00-0+