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

Comparing jsr166/src/test/loops/ConcurrentDequeLoops.java (file contents):
Revision 1.4 by jsr166, Mon Nov 2 23:42:46 2009 UTC vs.
Revision 1.12 by jsr166, Mon Aug 10 03:13:33 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   import java.util.*;
# Line 18 | Line 18 | public class ConcurrentDequeLoops {
18          int maxStages = 8;
19          int items = 1000000;
20  
21 <        Class klass = null;
21 >        Class<?> klass = null;
22          if (args.length > 0) {
23              try {
24                  klass = Class.forName(args[0]);
# Line 43 | Line 43 | public class ConcurrentDequeLoops {
43          Thread.sleep(100);
44          print = true;
45  
46 <        int k = 1;
47 <        for (int i = 1; i <= maxStages;) {
46 >        for (int k = 1, i = 1; i <= maxStages;) {
47              oneRun(klass, i, items);
48              if (i == k) {
49                  k = i << 1;
# Line 54 | Line 53 | public class ConcurrentDequeLoops {
53                  i = k;
54          }
55          pool.shutdown();
56 <   }
56 >    }
57  
58      static class Stage implements Callable<Integer> {
59          final Deque<Integer> queue;
60          final CyclicBarrier barrier;
61          final LoopHelpers.SimpleRandom rng = new LoopHelpers.SimpleRandom();
62          int items;
63 <        Stage (Deque<Integer> q, CyclicBarrier b, int items) {
63 >        Stage(Deque<Integer> q, CyclicBarrier b, int items) {
64              queue = q;
65              barrier = b;
66              this.items = items;
# Line 72 | Line 71 | public class ConcurrentDequeLoops {
71              // transform it, and put back in.
72              try {
73                  barrier.await();
74 <                int l = (int)System.nanoTime();
74 >                int l = (int) System.nanoTime();
75                  int takes = 0;
76                  for (;;) {
77                      Integer item;
# Line 117 | Line 116 | public class ConcurrentDequeLoops {
116          }
117      }
118  
119 <    static void oneRun(Class klass, int n, int items) throws Exception {
120 <        Deque<Integer> q = (Deque<Integer>)klass.newInstance();
119 >    static void oneRun(Class<?> klass, int n, int items) throws Exception {
120 >        Deque<Integer> q = (Deque<Integer>) klass.newInstance();
121          LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer();
122          CyclicBarrier barrier = new CyclicBarrier(n + 1, timer);
123          totalItems = new AtomicInteger(n * items);
# Line 141 | Line 140 | public class ConcurrentDequeLoops {
140              System.out.println(LoopHelpers.rightJustify(time / (items * n)) + " ns per item");
141          if (total == 0) // avoid overoptimization
142              System.out.println("useless result: " + total);
144
143      }
144   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines