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

Comparing jsr166/src/test/loops/OfferPollLoops.java (file contents):
Revision 1.2 by jsr166, Thu Oct 29 23:09:07 2009 UTC vs.
Revision 1.10 by jsr166, Sat Dec 31 19:29:58 2016 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.*;
8 < import java.util.concurrent.*;
9 < //import jsr166y.*;
7 > import java.util.Queue;
8 > import java.util.Random;
9 > import java.util.concurrent.ArrayBlockingQueue;
10 > import java.util.concurrent.CyclicBarrier;
11 > import java.util.concurrent.BlockingQueue;
12 > import java.util.concurrent.ConcurrentLinkedDeque;
13 > import java.util.concurrent.ConcurrentLinkedQueue;
14 > import java.util.concurrent.ExecutorService;
15 > import java.util.concurrent.Executors;
16 > import java.util.concurrent.LinkedBlockingDeque;
17 > import java.util.concurrent.LinkedBlockingQueue;
18 > import java.util.concurrent.LinkedTransferQueue;
19 > import java.util.concurrent.Phaser;
20 > import java.util.concurrent.PriorityBlockingQueue;
21  
22   public class OfferPollLoops {
23      static final int NCPUS = Runtime.getRuntime().availableProcessors();
# Line 54 | Line 65 | public class OfferPollLoops {
65  
66          warmup();
67          print = true;
68 <        int k = 1;
58 <        for (int i = 1; i <= maxN;) {
68 >        for (int k = 1, i = 1; i <= maxN;) {
69              System.out.println("Pairs:" + i);
70              oneTest(i, ITERS);
71              if (i == k) {
# Line 103 | Line 113 | public class OfferPollLoops {
113  
114          Thread.sleep(100); // System.gc();
115          if (print)
116 +            System.out.print("ConcurrentLinkedDeque   ");
117 +        oneRun(new ConcurrentLinkedDeque<Integer>(), n, iters);
118 +
119 +        Thread.sleep(100); // System.gc();
120 +        if (print)
121              System.out.print("LinkedBlockingQueue     ");
122          oneRun(new LinkedBlockingQueue<Integer>(), n, iters);
123  
# Line 121 | Line 136 | public class OfferPollLoops {
136              System.out.print("ArrayBlockingQueue      ");
137          oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE), n, iters);
138  
124
139          Thread.sleep(100); // System.gc();
140          if (print)
141              System.out.print("PriorityBlockingQueue   ");
# Line 131 | Line 145 | public class OfferPollLoops {
145          if (print)
146              System.out.print("ArrayBlockingQueue(fair)");
147          oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE, true), n, fairIters);
134
148      }
149  
150 <    static abstract class Stage implements Runnable {
150 >    abstract static class Stage implements Runnable {
151          final int iters;
152          final Queue<Integer> queue;
153          final CyclicBarrier barrier;
154          final Phaser lagPhaser;
155 <        Stage (Queue<Integer> q, CyclicBarrier b, Phaser s,
143 <               int iters) {
155 >        Stage(Queue<Integer> q, CyclicBarrier b, Phaser s, int iters) {
156              queue = q;
157              barrier = b;
158              lagPhaser = s;
# Line 233 | Line 245 | public class OfferPollLoops {
245              System.out.println("\t: " + LoopHelpers.rightJustify(time / (iters * n)) + " ns per transfer");
246      }
247  
236
248   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines