Search in sources :

Example 96 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer 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());
}
Also used : List(java.util.List) LazyReact(cyclops.futurestream.LazyReact) MaxActive(com.oath.cyclops.react.collectors.lazy.MaxActive) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SimpleTimer(com.oath.cyclops.util.SimpleTimer) ArrayList(java.util.ArrayList) LazyReact(cyclops.futurestream.LazyReact) SimpleTimer(com.oath.cyclops.util.SimpleTimer) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 97 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BatchingTest method judder.

@Test
public void judder() {
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).jitter(10000).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 98 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BatchingTest method onePer.

@Test
public void onePer() {
    SimpleTimer timer = new SimpleTimer();
    System.out.println(of(1, 2, 3, 4, 5, 6).onePer(1000, TimeUnit.NANOSECONDS).collect(Collectors.toList()));
    assertThat(of(1, 2, 3, 4, 5, 6).onePer(1000, TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(600l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 99 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BatchingTest method debounce.

@Test
public void debounce() {
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).debounce(1000, TimeUnit.SECONDS).collect(Collectors.toList()).size(), is(1));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Example 100 with SimpleTimer

use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.

the class BatchingTest method fixedDelay.

@Test
public void fixedDelay() {
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).fixedDelay(10000, TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), greaterThan(60000l));
}
Also used : SimpleTimer(com.oath.cyclops.util.SimpleTimer) Test(org.junit.Test)

Aggregations

SimpleTimer (com.oath.cyclops.util.SimpleTimer)103 Test (org.junit.Test)102 DuplicationTest (cyclops.futurestream.react.lazy.DuplicationTest)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Streamable (cyclops.companion.Streamable)3 MaxActive (com.oath.cyclops.react.collectors.lazy.MaxActive)2 LazyReact (cyclops.futurestream.LazyReact)2 SimpleReact (cyclops.futurestream.SimpleReact)2 LinkedList (java.util.LinkedList)2 ExecutionException (java.util.concurrent.ExecutionException)2 Collectors (java.util.stream.Collectors)2 AllArgsConstructor (lombok.AllArgsConstructor)2 Getter (lombok.Getter)2 Builder (lombok.experimental.Builder)2 Wither (lombok.experimental.Wither)2 Matchers.is (org.hamcrest.Matchers.is)2 Assert.assertThat (org.junit.Assert.assertThat)2 AbstractOrElseValueTest (cyclops.control.AbstractOrElseValueTest)1