rtest.c 1.1 KB

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