#include #include #include #include #include #include #include #include int main(int argc, char **argv) { int i, fd; time_t ts; char *fakebuf; if (argc < 2) exit(1); fd = open(argv[1], O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_NOFOLLOW, 0755); if (fd < 0) { perror("open"); exit(1); } fakebuf = malloc(256*1024); if (fakebuf == NULL) { perror("malloc"); exit(1); } ts = time(NULL); printf("writing.."); memset(fakebuf, 'A', 256*1024); for (i = 0; i < 68; i++) write(fd, fakebuf, 256*1024); printf("done in %lu secs\n", time(NULL) - ts); ts = time(NULL); printf("not syncing.."); // fsync(fd); printf("synced in %lu secs\n", time(NULL) - ts); printf("reading.."); ts = time(NULL); if (fd < 0) { perror("open"); exit(1); } // just mimic mysql stuff lseek(fd, 0, SEEK_CUR); lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); for (i = 0; i < 68; i++) read(fd, fakebuf, 256*1024); printf("done in %lu secs\n", time(NULL) - ts); return 0; }