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) { |
59 |
|
System.out.println("ITEMS: " + ITEMS + |
60 |
|
" CONSUMERS: " + CONSUMERS + |
61 |
|
" CAP: " + CAP); |
62 |
– |
|
62 |
|
for (int rep = 0; rep < reps; ++rep) { |
63 |
< |
long startTime = System.nanoTime(); |
64 |
< |
new Pub().fork(); |
66 |
< |
phaser.arriveAndAwaitAdvance(); |
67 |
< |
long elapsed = System.nanoTime() - startTime; |
68 |
< |
double secs = ((double)elapsed) / NPS; |
69 |
< |
System.out.printf("\tTime: %7.3f\n", secs); |
63 |
> |
oneRun(); |
64 |
> |
Thread.sleep(1000); |
65 |
|
} |
66 |
|
} |
67 |
+ |
|
68 |
+ |
static void oneRun() throws Exception { |
69 |
+ |
long startTime = System.nanoTime(); |
70 |
+ |
new Pub().fork(); |
71 |
+ |
phaser.arriveAndAwaitAdvance(); |
72 |
+ |
long elapsed = System.nanoTime() - startTime; |
73 |
+ |
double secs = ((double)elapsed) / NPS; |
74 |
+ |
System.out.printf("\tTime: %7.3f\n", secs); |
75 |
+ |
} |
76 |
+ |
|
77 |
|
} |