System.gc(); final BenchResult result = doBench(c, numThreads, bytes, size); printCell(String.format("%9.1f", result.mbps), c.getSimpleName().length()+1, out);
private static void doBench(final List<Class<? extends Checksum>> crcs, final PrintStream out) throws Exception { final byte[] bytes = new byte[MAX_LEN]; new Random().nextBytes(bytes); // Print header out.printf("\nPerformance Table (The unit is MB/sec; #T = #Theads)\n"); // Warm up implementations to get jit going. for (final Class<? extends Checksum> c : crcs) { doBench(c, 1, bytes, 2); doBench(c, 1, bytes, 2101); } // Test on a variety of sizes with different number of threads for (int size = 32; size <= MAX_LEN; size <<= 1) { doBench(crcs, bytes, size, out); } }
public static void main(final String args[]) throws Exception { printSystemProperties(System.out); doBench(CRCS, System.out); }