4 #include <sys/resource.h>
9 gettimeofday(&tv, NULL);
10 return tv.tv_sec + 1.0e-6*tv.tv_usec;
13 main(int argc, char *argv[])
18 int bufsize, sync, loops;
22 printf("usage: %s <bufsize> <sync> <loops>\n", argv[0]);
26 bufsize = atoi(argv[1]);
28 loops = atoi(argv[3]);
30 buf = (char *)malloc(bufsize);
32 memset(buf, 1, bufsize);
34 fd = open("sync.dat", O_CREAT|O_TRUNC|O_WRONLY | (sync?O_SYNC:0),0600);
37 for (i=0;i<loops;i++) {
38 write(fd, buf, bufsize);
43 printf("%g MB/sec\n", (1.0e-6*i*bufsize)/t);