Created
February 20, 2022 11:53
-
-
Save Park-Developer/d38511ac3b8b059b51cef0c3409ffc3d to your computer and use it in GitHub Desktop.
C ms time stamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#include <sys/time.h> | |
#include <unistd.h> | |
int main() { | |
struct timeval tv; | |
double begin, end; | |
// 시작하는 시간 받아오기 | |
gettimeofday(&tv, NULL); | |
begin = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000 ; | |
// 시간 측정을 진행할 부분 | |
usleep(1500000); | |
// 끝나는 시간 받아오기 | |
gettimeofday(&tv, NULL); | |
end = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000 ; | |
// 출력 | |
printf("Execution time %f\n", (end - begin) / 1000); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment