https://linux.die.net/man/3/clock_gettime


1
2
3
4
5
6
7
8
9
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
 
int64_t __getTimeNsec() {
    struct timespec now;
    clock_gettime(CLOCK_THREAD_CPUTIME_ID , &now);
    return (int64_t) now.tv_sec*1000000000LL + now.tv_nsec;
}
cs


이렇게 하면 cpu타임으로 계산하기 때문에 break를 걸어도 시간계산에 영향을 미치지 않음

+ Recent posts