--- jsr166/src/test/loops/TimeoutExchangerLoops.java 2007/02/19 00:46:06 1.3 +++ jsr166/src/test/loops/TimeoutExchangerLoops.java 2011/03/15 19:47:06 1.7 @@ -1,7 +1,7 @@ /* * Written by Bill Scherer and 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 + * explained at http://creativecommons.org/publicdomain/zero/1.0/ */ import java.util.concurrent.*; @@ -31,18 +31,18 @@ public class TimeoutExchangerLoops { patienceNanos = Long.parseLong(args[argc]); else if (option.equals("-r")) nReps = Integer.parseInt(args[argc]); - else + else maxThreads = Integer.parseInt(option); argc++; } - // Display runtime parameters - System.out.print("TimeoutExchangerTest"); - System.out.print(" -t " + trialMillis); - System.out.print(" -p " + patienceNanos); + // Display runtime parameters + System.out.print("TimeoutExchangerTest"); + System.out.print(" -t " + trialMillis); + System.out.print(" -p " + patienceNanos); System.out.print(" -r " + nReps); - System.out.print(" max threads " + maxThreads); - System.out.println(); + System.out.print(" max threads " + maxThreads); + System.out.println(); System.out.println("Warmups.."); long warmupTime = 1000; @@ -73,7 +73,7 @@ public class TimeoutExchangerLoops { } } - static void oneRun(int nThreads, long trialMillis, long patienceNanos) + static void oneRun(int nThreads, long trialMillis, long patienceNanos) throws Exception { System.out.printf("%4d threads", nThreads); System.out.printf("%9dms", trialMillis); @@ -89,10 +89,10 @@ public class TimeoutExchangerLoops { long startTime = System.nanoTime(); start.countDown(); Thread.sleep(trialMillis); - for (int i = 0; i < nThreads; ++i) + for (int i = 0; i < nThreads; ++i) threads[i].interrupt(); long elapsed = System.nanoTime() - startTime; - for (int i = 0; i < nThreads; ++i) + for (int i = 0; i < nThreads; ++i) threads[i].join(); int iters = 0; long fails = 0; @@ -103,7 +103,7 @@ public class TimeoutExchangerLoops { if (iters <= 0) iters = 1; long rate = iters * 1000L * 1000L * 1000L / elapsed; long npt = elapsed / iters; - double failRate = (fails * 100.0) / (double)iters; + double failRate = (fails * 100.0) / (double) iters; System.out.printf("%9d it/s ", rate); System.out.printf("%9d ns/it", npt); System.out.printf("%9.5f%% fails", failRate); @@ -153,4 +153,3 @@ public class TimeoutExchangerLoops { } } } -