ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/TimeoutExchangerLoops.java
(Generate patch)

Comparing jsr166/src/test/loops/TimeoutExchangerLoops.java (file contents):
Revision 1.2 by dl, Mon Feb 13 12:39:23 2006 UTC vs.
Revision 1.7 by jsr166, Tue Mar 15 19:47:06 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Bill Scherer and Doug Lea with assistance from members
3 < * of JCP JSR-166 Expert Group and released to the public domain. Use,
4 < * modify, and redistribute this code in any way without
5 < * acknowledgement.
3 > * of JCP JSR-166 Expert Group and released to the public domain, as
4 > * explained at http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   import java.util.concurrent.*;
# Line 32 | Line 31 | public class TimeoutExchangerLoops {
31                  patienceNanos = Long.parseLong(args[argc]);
32              else if (option.equals("-r"))
33                  nReps = Integer.parseInt(args[argc]);
34 <            else
34 >            else
35                  maxThreads = Integer.parseInt(option);
36              argc++;
37          }
38  
39 <        // Display runtime parameters
40 <        System.out.print("TimeoutExchangerTest");
41 <        System.out.print(" -t " + trialMillis);
42 <        System.out.print(" -p " + patienceNanos);
39 >        // Display runtime parameters
40 >        System.out.print("TimeoutExchangerTest");
41 >        System.out.print(" -t " + trialMillis);
42 >        System.out.print(" -p " + patienceNanos);
43          System.out.print(" -r " + nReps);
44 <        System.out.print(" max threads " + maxThreads);
45 <        System.out.println();
44 >        System.out.print(" max threads " + maxThreads);
45 >        System.out.println();
46  
47          System.out.println("Warmups..");
48          long warmupTime = 1000;
# Line 74 | Line 73 | public class TimeoutExchangerLoops {
73          }
74      }
75  
76 <    static void oneRun(int nThreads, long trialMillis, long patienceNanos)
76 >    static void oneRun(int nThreads, long trialMillis, long patienceNanos)
77          throws Exception {
78          System.out.printf("%4d threads", nThreads);
79          System.out.printf("%9dms", trialMillis);
# Line 90 | Line 89 | public class TimeoutExchangerLoops {
89          long startTime = System.nanoTime();
90          start.countDown();
91          Thread.sleep(trialMillis);
92 <        for (int i = 0; i < nThreads; ++i)
92 >        for (int i = 0; i < nThreads; ++i)
93              threads[i].interrupt();
94          long elapsed = System.nanoTime() - startTime;
95 <        for (int i = 0; i < nThreads; ++i)
95 >        for (int i = 0; i < nThreads; ++i)
96              threads[i].join();
97          int iters = 0;
98          long fails = 0;
# Line 104 | Line 103 | public class TimeoutExchangerLoops {
103          if (iters <= 0) iters = 1;
104          long rate = iters * 1000L * 1000L * 1000L / elapsed;
105          long npt = elapsed / iters;
106 <        double failRate = (fails * 100.0) / (double)iters;
106 >        double failRate = (fails * 100.0) / (double) iters;
107          System.out.printf("%9d it/s ", rate);
108          System.out.printf("%9d ns/it", npt);
109          System.out.printf("%9.5f%% fails", failRate);
# Line 154 | Line 153 | public class TimeoutExchangerLoops {
153          }
154      }
155   }
157        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines