--- jsr166/src/test/loops/MapWordLoops.java 2009/10/23 19:57:06 1.4 +++ jsr166/src/test/loops/MapWordLoops.java 2009/10/29 23:09:07 1.5 @@ -9,12 +9,12 @@ import java.io.*; public class MapWordLoops { static final String[] WORDS_FILES = { - "kw.txt", + "kw.txt", "class.txt", "dir.txt", - "ids.txt", + "ids.txt", "testwords.txt", - // "/usr/dict/words", + // "/usr/dict/words", }; static final int MAX_WORDS = 500000; @@ -34,22 +34,22 @@ public class MapWordLoops { System.out.println("Testing " + mapClass.getName()); - for (int s = 0; s < WORDS_FILES.length; ++s) + for (int s = 0; s < WORDS_FILES.length; ++s) tests(mapClass, numTests, s); - for (int s = WORDS_FILES.length-1; s >= 0; --s) + for (int s = WORDS_FILES.length-1; s >= 0; --s) tests(mapClass, numTests, s); } static void tests(Class mapClass, int numTests, int sizeIndex) { - try { + try { String[] key = readWords(sizeIndex); int size = key.length; - + System.out.print("n = " +LoopHelpers.rightJustify(size) +" : "); long least = Long.MAX_VALUE; - + for (int i = 0; i < numTests; ++i) { Map m = newMap(mapClass); long t = doTest(i, mapClass.getName(), m, key); @@ -57,7 +57,7 @@ public class MapWordLoops { m.clear(); m = null; } - + long nano = Math.round(1000000.0 * (least) / NOPS); System.out.println(LoopHelpers.rightJustify(nano) + " ns per op"); } catch (IOException ignore) { @@ -107,7 +107,7 @@ public class MapWordLoops { } static long doTest(int id, String name, - final Map m, + final Map m, final String[] key) { // System.out.print(name + "\t"); @@ -117,10 +117,10 @@ public class MapWordLoops { long afterRun = System.currentTimeMillis(); long runTime = (afterRun - startTime); int np = runner.total; - if (runner.total == runner.hashCode()) + if (runner.total == runner.hashCode()) System.out.println("Useless Number" + runner.total); int sz = runner.maxsz; - if (sz == runner.hashCode()) + if (sz == runner.hashCode()) System.out.println("Useless Number" + sz); // System.out.print(" m = " + sz); return runTime; @@ -141,7 +141,7 @@ public class MapWordLoops { int maxsz; Runner(int id, Map m, String[] k) { - map = m; key = k; + map = m; key = k; pctrem = (int)(((long)premove * (long)(Integer.MAX_VALUE/2)) / 50); pctins = (int)(((long)pinsert * (long)(Integer.MAX_VALUE/2)) / 50); rng = new LoopHelpers.SimpleRandom((id + 1) * 8862213513L); @@ -153,15 +153,15 @@ public class MapWordLoops { int r = rng.next() & 0x7FFFFFFF; int jinc = (r & 7); j += jinc - 3; - if (j >= n) j -= n; + if (j >= n) j -= n; if (j < 0) j += n; int l = n / 4 + j; - if (l >= n) l -= n; - + if (l >= n) l -= n; + String k = key[j]; String x = map.get(k); - + if (x == null) { ++nagets; if (r < pctins) {