Example #1
0
 private static void benchDouble(ArrayFile af, int n) throws IOException {
   double[] a = randdouble(n);
   double[] b = zerodouble(n);
   int nio;
   Stopwatch sw = new Stopwatch();
   sw.start();
   for (nio = 0; sw.time() < 5.0; ++nio) {
     af.seek(0);
     af.writeDoubles(a);
     af.seek(0);
     af.readDoubles(b);
   }
   sw.stop();
   for (int i = 0; i < n; ++i) if (a[i] != b[i]) throw new RuntimeException("double: i/o failure");
   double time = sw.time();
   double rate = 2.0 * 8.0e-6 * nio * n / time;
   System.out.println("double: rate=" + rate + " MB/s");
 }