Blob


1 #include "stdinc.h"
3 enum {
4 Nblock = 300000,
5 BlockSize = 8*1024
6 };
8 uchar data[Nblock*VtScoreSize];
9 int rflag;
10 int nblock = 10000;
11 int perm[Nblock];
13 void
14 main(int argc, char *argv[])
15 {
16 VtSession *z;
17 int i, j, t;
18 int start;
19 uchar buf[BlockSize];
21 srand(time(0));
23 ARGBEGIN{
24 case 'r':
25 rflag++;
26 break;
27 case 'n':
28 nblock = atoi(ARGF());
29 break;
30 }ARGEND
32 for(i=0; i<nblock; i++)
33 perm[i] = i;
35 if(rflag) {
36 for(i=0; i<nblock; i++) {
37 j = nrand(nblock);
38 t = perm[j];
39 perm[j] = perm[i];
40 perm[i] = t;
41 }
42 }
44 if(readn(0, data, VtScoreSize*nblock) < VtScoreSize*nblock)
45 sysfatal("read failed: %r");
47 vtAttach();
49 z = vtDial("iolaire2");
50 if(z == nil)
51 sysfatal("cound not connect to venti");
52 if(!vtConnect(z, 0))
53 vtFatal("vtConnect: %s", vtGetError());
55 print("starting\n");
57 start = times(0);
59 if(rflag && nblock > 10000)
60 nblock = 10000;
62 for(i=0; i<nblock; i++) {
63 if(vtRead(z, data+perm[i]*VtScoreSize, VtDataType, buf, BlockSize) < 0)
64 vtFatal("vtRead failed: %d: %s", i, vtGetError());
65 }
67 print("time = %f\n", (times(0) - start)*0.001);
69 vtClose(z);
70 vtDetach();
71 }