--- jsr166/src/test/loops/DenseMapMicroBenchmark.java 2011/03/15 19:47:05 1.6 +++ jsr166/src/test/loops/DenseMapMicroBenchmark.java 2016/10/23 03:03:23 1.10 @@ -47,13 +47,13 @@ public class DenseMapMicroBenchmark { time0(NANOS_PER_JOB, jobs); final String nameHeader = "Method"; - int nameWidth = nameHeader.length(); + int nameWidth = nameHeader.length(); for (Job job : jobs) nameWidth = Math.max(nameWidth, job.name().length()); final int itemsPerTest = SIZE * OPS_PER_ITER * ITERS_PER_TEST; final String timeHeader = "Nanos/item"; - int timeWidth = timeHeader.length(); + int timeWidth = timeHeader.length(); final String ratioHeader = "Ratio"; int ratioWidth = ratioHeader.length(); String format = String.format("%%-%ds %%%dd %%.3f%%n", @@ -70,7 +70,6 @@ public class DenseMapMicroBenchmark { } } - static Long[] toLongs(Integer[] ints) { Long[] longs = new Long[ints.length]; for (int i = 0; i < ints.length; i++) @@ -100,20 +99,19 @@ public class DenseMapMicroBenchmark { return doubles; } - static final class Hasher extends Job { final Object[] elts; - final Class mapClass; + final Class mapClass; volatile int matches; - Hasher(String name, Object[] elts, Class mapClass) { + Hasher(String name, Object[] elts, Class mapClass) { super(name); this.elts = elts; this.mapClass = mapClass; } public void work() { - Map m = null; + final Map m; try { - m = (Map) mapClass.newInstance(); + m = (Map) mapClass.getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Can't instantiate " + mapClass + ": " + e); } @@ -151,7 +149,7 @@ public class DenseMapMicroBenchmark { } public static void main(String[] args) throws Throwable { - Class mc = java.util.HashMap.class; + Class mc = java.util.HashMap.class; if (args.length > 0) mc = Class.forName(args[0]); if (args.length > 1)