Search in sources :

Example 56 with SimpleTimer

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

the class AlgorithmCompareTest method testFastestLessBlocking.

@Test
public void testFastestLessBlocking() throws InterruptedException, ExecutionException {
    ArrayList<Integer> arrayList = new ArrayList<>();
    LinkedList<Integer> linkedList = new LinkedList<>();
    for (int i = 0; i < 1001; i++) {
        arrayList.add(i);
        linkedList.add(i);
    }
    SimpleTimer timer = new SimpleTimer();
    Result result = new SimpleReact().<Result>ofAsync(() -> Result.builder().name("approach1 : arrayList").result(retrieval(arrayList)).build(), () -> Result.builder().name("approach2 : linkedList").result(retrieval(linkedList)).build()).then(it -> it.withTime(timer.getElapsedNanoseconds())).filter(it -> it.getResult() == 1000).block().firstValue(null);
    assertThat(result.getName(), is("approach1 : arrayList"));
}
Also used : Getter(lombok.Getter) Wither(lombok.experimental.Wither) Test(org.junit.Test) SimpleTimer(com.oath.cyclops.util.SimpleTimer) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) Builder(lombok.experimental.Builder) SimpleReact(cyclops.futurestream.SimpleReact) Matchers.is(org.hamcrest.Matchers.is) LinkedList(java.util.LinkedList) AllArgsConstructor(lombok.AllArgsConstructor) SimpleTimer(com.oath.cyclops.util.SimpleTimer) SimpleReact(cyclops.futurestream.SimpleReact) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 57 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(DuplicationTest.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) DuplicationTest(cyclops.futurestream.react.lazy.DuplicationTest)

Example 58 with SimpleTimer

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

the class BatchingTest method xPer.

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

Example 59 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(DuplicationTest.of(1, 2, 3, 4, 5, 6).onePer(1000, TimeUnit.NANOSECONDS).collect(Collectors.toList()));
    assertThat(DuplicationTest.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) DuplicationTest(cyclops.futurestream.react.lazy.DuplicationTest)

Example 60 with SimpleTimer

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

the class AbstractIterableXTest method xPer.

@Test
public void xPer() {
    SimpleTimer timer = new SimpleTimer();
    assertThat(of(1, 2, 3, 4, 5, 6).xPer(6, 100000000, TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(), is(6));
    assertThat(timer.getElapsedNanoseconds(), lessThan(60000000l));
}
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