--- jsr166/src/test/loops/MapWordLoops.java 2005/05/02 19:19:38 1.1 +++ jsr166/src/test/loops/MapWordLoops.java 2009/10/23 19:57:06 1.4 @@ -1,3 +1,8 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/licenses/publicdomain + */ import java.util.*; import java.io.*; @@ -8,13 +13,15 @@ public class MapWordLoops { "class.txt", "dir.txt", "ids.txt", - "/usr/dict/words", + "testwords.txt", + // "/usr/dict/words", }; static final int MAX_WORDS = 500000; static final int pinsert = 60; - static final int premove = 1; - static final int NOPS = 5000000; + static final int premove = 2; + static final int NOPS = 8000000; + static final int numTests = 3; public static void main(String[] args) { @@ -45,7 +52,7 @@ public class MapWordLoops { for (int i = 0; i < numTests; ++i) { Map m = newMap(mapClass); - long t = doTest(mapClass.getName(), m, key); + long t = doTest(i, mapClass.getName(), m, key); if (t < least) least = t; m.clear(); m = null; @@ -99,12 +106,12 @@ public class MapWordLoops { return array; } - static long doTest(String name, + static long doTest(int id, String name, final Map m, final String[] key) { // System.out.print(name + "\t"); - Runner runner = new Runner(m, key); + Runner runner = new Runner(id, m, key); long startTime = System.currentTimeMillis(); runner.run(); long afterRun = System.currentTimeMillis(); @@ -123,7 +130,7 @@ public class MapWordLoops { static class Runner implements Runnable { final Map map; final String[] key; - LoopHelpers.SimpleRandom rng = new LoopHelpers.SimpleRandom(); + LoopHelpers.SimpleRandom rng; final int pctrem; final int pctins; int nputs = 0; @@ -133,10 +140,11 @@ public class MapWordLoops { volatile int total; int maxsz; - Runner(Map m, String[] k) { + Runner(int id, Map m, String[] 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); }