]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/aux/seek.c
exec(2): fix prototypes
[plan9front.git] / sys / src / cmd / aux / seek.c
1 #include <u.h>
2 #include <libc.h>
3
4 void
5 main(int argc, char **argv)
6 {
7         char buf[512];
8         vlong size;
9         vlong pos;
10         vlong ns;
11         int fd;
12         int i;
13
14         if(argc != 2) {
15                 fprint(2, "usage: %s /dev/sd??/data\n", argv[0]);
16                 exits("usage");
17         }
18         
19         srand(time(0));
20         fd = open(argv[1], OREAD);
21         if(fd < 0)
22                 sysfatal("open: %r");
23         size = seek(fd, 0, 2) / 512;
24         ns = nsec();
25         for(i=0;i<100;i++) {
26                 pos = (vlong)(frand() * size);
27                 if(pread(fd, buf, 512, 512 * pos) < 512)
28                         sysfatal("read: %r");
29         }
30         ns = nsec() - ns;
31         print("%.3g\n", ((double)ns)/100000000);
32         exits(nil);
33 }