use of reactor.core.scheduler.Scheduler in project reactor-core by reactor.
the class ParallelMergeReduceTest method parallelReduceFull.
@Test
public void parallelReduceFull() {
int m = 100_000;
for (int n = 1; n <= m; n *= 10) {
// System.out.println(n);
for (int i = 1; i <= Runtime.getRuntime().availableProcessors(); i++) {
// System.out.println(" " + i);
Scheduler scheduler = Schedulers.newParallel("test", i);
try {
AssertSubscriber<Long> ts = AssertSubscriber.create();
Flux.range(1, n).map(v -> (long) v).parallel(i).runOn(scheduler).reduce((a, b) -> a + b).subscribe(ts);
ts.await(Duration.ofSeconds(500));
long e = ((long) n) * (1 + n) / 2;
ts.assertValues(e);
} finally {
scheduler.dispose();
}
}
}
}
Aggregations