-
-
Save tanakamura/a7007346543cb6bc9fbd7e387d970404 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#define _GNU_SOURCE | |
#include <time.h> | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
double f_freq; | |
double | |
getsec(void) | |
{ | |
struct timespec ts; | |
clock_gettime(CLOCK_MONOTONIC, &ts); | |
return ts.tv_sec + ts.tv_nsec/1000000000.0; | |
} | |
int main() | |
{ | |
double t0, t1; | |
FILE *a = fopen("a.txt", "wb"); | |
fclose(a); | |
for (int i=0; i<4; i++) { | |
int nloop = 4096; | |
t0 = getsec(); | |
for (int li=0; li<nloop; li++) { | |
int fd = open("a.txt", O_RDWR); | |
close(fd); | |
} | |
t1 = getsec(); | |
printf("%f[usec]\n", ((t1-t0)/nloop)*1000000.0); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment