use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class ReactToList method main.
public static void main(String[] args) {
List<Integer> values = new ArrayList();
for (int i = 0; i < 4000; i++) values.add(i);
LazyReact lazy = LazyReact.sequentialCurrentBuilder().withAsync(false).withMaxActive(new MaxActive(4010, 1000));
SimpleTimer t = new SimpleTimer();
for (int x = 0; x < 1000; x++) {
res = lazy.from(values).map(i -> i + 2).map(i -> i * 3).collect(Collectors.toList());
}
System.out.println(t.getElapsedNanoseconds());
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class ReactToList method parallel.
@Test
public void parallel() {
List<Integer> values = new ArrayList();
for (int i = 0; i < 4000; i++) values.add(i);
LazyReact lazy = LazyReact.parallelBuilder(8).autoOptimizeOn().withMaxActive(MaxActive.CPU);
SimpleTimer t = new SimpleTimer();
for (int x = 0; x < 1000; x++) {
res = lazy.from(values).map(i -> i + 2).map(i -> i * 3).collect(Collectors.toList());
}
System.out.println(t.getElapsedNanoseconds());
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class CaptureTest method captureLazy.
@Test
public void captureLazy() {
t = null;
new LazyReact().of("hello", "world").capture(e -> t = e).peek(System.out::println).then(this::exception).forEach(System.out::println);
assertNotNull(t);
assertFalse(t.toString(), t instanceof SimpleReactFailedStageException);
assertTrue(t.toString(), t instanceof InternalException);
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class SimpleReactTest method testLazyParameters.
@Test
public void testLazyParameters() {
ForkJoinPool fjp = new ForkJoinPool();
assertThat(new LazyReact(fjp).getExecutor(), is(fjp));
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class ReactPoolTest method testElastic.
@Test
public void testElastic() {
for (int i = 0; i < 1000; i++) {
ReactPool<LazyReact> pool = ReactPool.elasticPool(() -> new LazyReact());
List<String> result = pool.react((er) -> er.ofAsync(() -> "hello", () -> "world").block());
assertThat(result.size(), is(2));
}
}
Aggregations