Ejemplo n.º 1
0
 private static void bench(ByteOrder order) {
   System.out.println("order=" + order);
   int n = 1000000;
   try {
     File file = File.createTempFile("junk", "dat");
     file.deleteOnExit();
     ArrayFile af = new ArrayFile(file, "rw", order, order);
     benchFloat(af, n);
     benchDouble(af, n);
     af.close();
   } catch (IOException ioe) {
     throw new RuntimeException(ioe);
   }
 }
Ejemplo n.º 2
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");
 }