Skip to content

Instantly share code, notes, and snippets.

@Park-Developer
Created February 20, 2022 11:53
Show Gist options
  • Save Park-Developer/d38511ac3b8b059b51cef0c3409ffc3d to your computer and use it in GitHub Desktop.
Save Park-Developer/d38511ac3b8b059b51cef0c3409ffc3d to your computer and use it in GitHub Desktop.
C ms time stamp
#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