[ C++ ] Time Clock
1.Time
time_t t1, t2; // typedef time_t long; t1 = time(NULL); Sleep(1234); t2 = time(NULL); printf("%ld secs\n", t2-t1);
result:1 sec
2.clock
clock_t t1, t2; t1 = clock(); Sleep(1234); t2 = clock(); printf("%lf\n", (t2-t1)/(double)(CLOCKS_PER_SEC));
result : 1.234000sec
留言
張貼留言