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

Comparing jsr166/src/test/loops/SubmissionPublisherLoops1.java (file contents):
Revision 1.3 by dl, Fri Jul 24 11:50:43 2015 UTC vs.
Revision 1.5 by dl, Mon Apr 18 11:04:14 2016 UTC

# Line 18 | Line 18 | public class SubmissionPublisherLoops1 {
18  
19      static final Phaser phaser = new Phaser(CONSUMERS + 1);
20  
21 <    static class Sub implements Flow.Subscriber<Boolean> {
21 >    static final class Sub implements Flow.Subscriber<Boolean> {
22          Flow.Subscription sn;
23          int count;
24          public void onSubscribe(Flow.Subscription s) {
# Line 48 | Line 48 | public class SubmissionPublisherLoops1 {
48                             " CAP: " + CAP);
49          ExecutorService exec = ForkJoinPool.commonPool();
50          for (int rep = 0; rep < reps; ++rep) {
51 <            long startTime = System.nanoTime();
52 <            final SubmissionPublisher<Boolean> pub =
53 <                new SubmissionPublisher<Boolean>(exec, CAP);
54 <            for (int i = 0; i < CONSUMERS; ++i)
55 <                pub.subscribe(new Sub());
56 <            for (int i = 0; i < ITEMS; ++i) {
57 <                pub.submit(Boolean.TRUE);
58 <            }
59 <            pub.close();
60 <            phaser.arriveAndAwaitAdvance();
61 <            long elapsed = System.nanoTime() - startTime;
62 <            double secs = ((double)elapsed) / NPS;
63 <            System.out.printf("\tTime: %7.3f\n", secs);
64 <            //            System.out.println(exec);
51 >            oneRun(exec);
52 >            System.out.println(exec);
53              Thread.sleep(1000);
54          }
55          if (exec != ForkJoinPool.commonPool())
56              exec.shutdown();
57      }
58 +
59 +    static void oneRun(ExecutorService exec) throws Exception {
60 +        long startTime = System.nanoTime();
61 +        final SubmissionPublisher<Boolean> pub =
62 +            new SubmissionPublisher<Boolean>(exec, CAP);
63 +        for (int i = 0; i < CONSUMERS; ++i)
64 +            pub.subscribe(new Sub());
65 +        for (int i = 0; i < ITEMS; ++i) {
66 +            pub.submit(Boolean.TRUE);
67 +        }
68 +        pub.close();
69 +        phaser.arriveAndAwaitAdvance();
70 +        long elapsed = System.nanoTime() - startTime;
71 +        double secs = ((double)elapsed) / NPS;
72 +        System.out.printf("\tTime: %7.3f\n", secs);
73 +    }
74   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines