--- jsr166/src/test/loops/StringMapLoops.java 2009/11/02 23:42:46 1.5 +++ jsr166/src/test/loops/StringMapLoops.java 2014/12/18 18:43:22 1.11 @@ -1,7 +1,7 @@ /* * 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 + * http://creativecommons.org/publicdomain/zero/1.0/ */ import java.util.*; @@ -20,7 +20,7 @@ public class StringMapLoops { public static void main(String[] args) throws Exception { - Class mapClass = null; + Class mapClass = null; if (args.length > 0) { try { mapClass = Class.forName(args[0]); @@ -60,9 +60,8 @@ public class StringMapLoops { String[] key = makeKeys(nkeys); - int k = 1; int warmups = 2; - for (int i = 1; i <= maxThreads;) { + for (int k = 1, i = 1; i <= maxThreads;) { Thread.sleep(100); test(i, nkeys, key, mapClass); shuffleKeys(key); @@ -96,13 +95,13 @@ public class StringMapLoops { char[] c = new char[len * 4]; for (int j = 0; j < len; ++j) { int r = rng.next(); - c[k++] = (char)(' ' + (r & 0x7f)); + c[k++] = (char) (' ' + (r & 0x7f)); r >>>= 8; - c[k++] = (char)(' ' + (r & 0x7f)); + c[k++] = (char) (' ' + (r & 0x7f)); r >>>= 8; - c[k++] = (char)(' ' + (r & 0x7f)); + c[k++] = (char) (' ' + (r & 0x7f)); r >>>= 8; - c[k++] = (char)(' ' + (r & 0x7f)); + c[k++] = (char) (' ' + (r & 0x7f)); } key[i] = new String(c); } @@ -119,7 +118,7 @@ public class StringMapLoops { } } - static void test(int i, int nkeys, String[] key, Class mapClass) throws Exception { + static void test(int i, int nkeys, String[] key, Class mapClass) throws Exception { System.out.print("Threads: " + i + "\t:"); Map map = (Map)mapClass.newInstance(); // Uncomment to start with a non-empty table @@ -133,9 +132,9 @@ public class StringMapLoops { barrier.await(); barrier.await(); long time = timer.getTime(); - long tpo = time / (i * (long)nops); + long tpo = time / (i * (long) nops); System.out.print(LoopHelpers.rightJustify(tpo) + " ns per op"); - double secs = (double)(time) / 1000000000.0; + double secs = (double) time / 1000000000.0; System.out.println("\t " + secs + "s run time"); map.clear(); } @@ -148,7 +147,7 @@ public class StringMapLoops { int position; int total; - Runner(int id, Map map, String[] key, CyclicBarrier barrier) { + Runner(int id, Map map, String[] key, CyclicBarrier barrier) { this.map = map; this.key = key; this.barrier = barrier; @@ -158,7 +157,7 @@ public class StringMapLoops { } int step() { - // random-walk around key positions, bunching accesses + // random-walk around key positions, bunching accesses int r = rng.next(); position += (r & 7) - 3; while (position >= key.length) position -= key.length;