#include #include #include #include #include #include int main(int ac, char *av[]) { int fd = open(av[1], O_RDONLY); if (fd == -1) { perror("open"); exit(-1); } char buf[8192]; off_t total = 0; for (;;) { struct timeval start, end, diff; gettimeofday(&start, NULL); int bytes_read = read(fd, buf, sizeof buf); gettimeofday(&end, NULL); timersub(&end, &start, &diff); printf("%ld: took %ldus\n", total, diff.tv_sec * 1000000 + diff.tv_usec); if (bytes_read <= 0) break; total += bytes_read; } return 0; }