徒労のまとめ

  • 入力は、System.in.read(byte[], int, int) を使ってバッファリングするのが速い(らしい)。
  • 出力は、単一のバイトなら System.out.out.write(int)、複数なら System.out.out.write(byte[], int, int) が速い(らしい):
/* import java.io.*;
   import java.lang.reflect.*; */
Field f = FilterOutputStream.class.getDeclaredField("out");
f.setAccessible(true);
OutputStream out = (OutputStream)f.get(System.out);
/* ... out.write() ... */
out.flush();
  • メモリアクセスの非局所性は馬鹿にならない(らしい)。
  • クイックソート再帰しない方が速い(らしい)。
  • そして無駄にした時間は返ってこない。