10 struct timeval tp1,tp2;
12 static void start_timer()
14 gettimeofday(&tp1,NULL);
17 static double end_timer()
19 gettimeofday(&tp2,NULL);
20 return((tp2.tv_sec - tp1.tv_sec) +
21 (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
24 int main(int argc, char *argv[])
31 printf("Usage: pipespeed megabytes\n");
35 memset(buf,'Z',BUFSIZE);
37 size = atoi(argv[1]) * 0x100000;
39 fd = open("/dev/null", O_WRONLY);
45 if (pipe(fdpair) != 0) {
53 int n = read(fdpair[0], buf, BUFSIZE);
66 int n = write(fdpair[1], buf, BUFSIZE);
68 printf("pipe write error\n");
74 printf("%g MB/sec\n", (i/(0x100000))/end_timer());