--- jsr166/src/test/loops/MapMicroBenchmark.java 2011/03/15 19:47:05 1.10 +++ jsr166/src/test/loops/MapMicroBenchmark.java 2014/12/31 17:00:58 1.16 @@ -4,9 +4,9 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.*; import java.io.*; import java.math.*; +import java.util.*; /** * A micro-benchmark with key types and operation mixes roughly @@ -38,7 +38,7 @@ import java.math.*; public class MapMicroBenchmark { static final String wordFile = "testwords.txt"; - static Class mapClass; + static Class mapClass; static boolean randomSearches = true; // Nanoseconds per run @@ -147,7 +147,7 @@ public class MapMicroBenchmark { } static void runWork(Job[] jobs, int minIters, int maxIters, long timeLimit) throws Throwable { - for (int k = 0; k < nsizes; ++k) { + for (int k = 0; k < nsizes; ++k) { int len = sizes[k]; for (int i = 0; i < jobs.length; i++) { Thread.sleep(50); @@ -160,7 +160,7 @@ public class MapMicroBenchmark { // First warmup -- run only mixed job to discourage type specialization static void warmup1(Job job) throws Throwable { - for (int k = 0; k < nsizes; ++k) + for (int k = 0; k < nsizes; ++k) job.work(sizes[k], 1, 1, 0); } @@ -213,13 +213,13 @@ public class MapMicroBenchmark { static final class Job { final String name; - final Class elementClass; + final Class elementClass; long[] nanos = new long[nsizes]; final Object[] items; Object[] searches; volatile long checkSum; volatile int lastSum; - Job(String name, Object[] items, Class elementClass) { + Job(String name, Object[] items, Class elementClass) { this.name = name; this.items = items; this.elementClass = elementClass; @@ -334,6 +334,12 @@ public class MapMicroBenchmark { if (m.put(x, x) == null) ++sum; } + /* // uncomment to avoid calling clear() + for (int i = 0; i < len; ++i) { + Object x = keys[i]; + m.remove(x); + } + */ m.clear(); sum += len - (quarter * 2); checkSum += sum ^ (sum << 12); @@ -377,7 +383,7 @@ public class MapMicroBenchmark { // plain array shuffle static void shuffle(Object[] a, int size) { - for (int i= size; i>1; i--) { + for (int i = size; i > 1; i--) { Object t = a[i-1]; int r = rng.nextInt(i); a[i-1] = a[r]; @@ -438,7 +444,7 @@ public class MapMicroBenchmark { BufferedInputStream in = new BufferedInputStream(fr); int k = 0; - outer:while (k < n) { + outer: while (k < n) { StringBuffer sb = new StringBuffer(); for (;;) { int c = in.read();