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.11 by jsr166, Sat Dec 31 19:50:56 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();
13    static final Random rng = new Random();
24      static final ExecutorService pool = Executors.newCachedThreadPool();
25      static boolean print = false;
26      static int producerSum;
# Line 54 | Line 64 | public class OfferPollLoops {
64  
65          warmup();
66          print = true;
67 <        int k = 1;
58 <        for (int i = 1; i <= maxN;) {
67 >        for (int k = 1, i = 1; i <= maxN;) {
68              System.out.println("Pairs:" + i);
69              oneTest(i, ITERS);
70              if (i == k) {
# Line 103 | Line 112 | public class OfferPollLoops {
112  
113          Thread.sleep(100); // System.gc();
114          if (print)
115 +            System.out.print("ConcurrentLinkedDeque   ");
116 +        oneRun(new ConcurrentLinkedDeque<Integer>(), n, iters);
117 +
118 +        Thread.sleep(100); // System.gc();
119 +        if (print)
120              System.out.print("LinkedBlockingQueue     ");
121          oneRun(new LinkedBlockingQueue<Integer>(), n, iters);
122  
# Line 121 | Line 135 | public class OfferPollLoops {
135              System.out.print("ArrayBlockingQueue      ");
136          oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE), n, iters);
137  
124
138          Thread.sleep(100); // System.gc();
139          if (print)
140              System.out.print("PriorityBlockingQueue   ");
# Line 131 | Line 144 | public class OfferPollLoops {
144          if (print)
145              System.out.print("ArrayBlockingQueue(fair)");
146          oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE, true), n, fairIters);
134
147      }
148  
149 <    static abstract class Stage implements Runnable {
149 >    abstract static class Stage implements Runnable {
150          final int iters;
151          final Queue<Integer> queue;
152          final CyclicBarrier barrier;
153          final Phaser lagPhaser;
154 <        Stage (Queue<Integer> q, CyclicBarrier b, Phaser s,
143 <               int iters) {
154 >        Stage(Queue<Integer> q, CyclicBarrier b, Phaser s, int iters) {
155              queue = q;
156              barrier = b;
157              lagPhaser = s;
# Line 233 | Line 244 | public class OfferPollLoops {
244              System.out.println("\t: " + LoopHelpers.rightJustify(time / (iters * n)) + " ns per transfer");
245      }
246  
236
247   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines