cyclops.reactive.ReactiveSeq.xPer()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中cyclops.reactive.ReactiveSeq.xPer方法的一些代码示例,展示了ReactiveSeq.xPer的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.xPer方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:xPer

ReactiveSeq.xPer介绍

[英]emit x elements per time period

code

[中]每个时间段发射x个元素

code

代码示例

代码示例来源:origin: aol/cyclops

/**
 * emit x elements per time period
 *
 * <pre>
 * {@code
 *  SimpleTimer timer = new SimpleTimer();
  assertThat(Streamable.of(1,2,3,4,5,6)
            .xPer(6,100000000,TimeUnit.NANOSECONDS)
            .collect(CyclopsCollectors.toList()).size(),is(6));
 * }
 * </pre>
 * @param x number of elements to emit
 * @param time period
 * @param t Time unit
 * @return Streamable that emits x elements per time period
 */
default ReactiveSeq<T> xPer(final int x, final long time, final TimeUnit t) {
  return this.stream().xPer(x, time, t);
}

代码示例来源:origin: aol/cyclops

/**
 * emit x elements per time period
 *
 * <pre>
 * {@code
 *  SimpleTimer timer = new SimpleTimer();
  ReactiveSeq.of(1, 2, 3, 4, 5, 6)
        .xPer(6, 100000000, TimeUnit.NANOSECONDS)
        .collect(CyclopsCollectors.toList())
        .size()
  //6
 *
 * }
 * </pre>
 *
 * @param x
 *            number of elements to emit
 * @param time
 *            period
 * @param t
 *            Time unit
 * @return ReactiveSeq that emits x elements per time period
 */
default ReactiveSeq<T> xPer(final int x, final long time, final TimeUnit t) {
  return stream().xPer(x, time, t);
}

代码示例来源:origin: aol/cyclops

@Test
public void xPerSecond() throws InterruptedException {
  Thread.sleep(500);
  long start = System.currentTimeMillis();
      iterate(1, it -> it + 1)
      .xPer(1,1, TimeUnit.SECONDS)
      .limit(3)
      .map(seconds -> "hello!")
      .peek(System.out::println)
      .toList();
 System.out.println("time = " +(System.currentTimeMillis()-start));
 assertTrue("failed time was " + (System.currentTimeMillis()-start),System.currentTimeMillis()-start>1600);
}

代码示例来源:origin: aol/cyclops

@Test
public void xPerSecond() throws InterruptedException {
  Thread.sleep(500);
  long start = System.currentTimeMillis();
      iterate(1, it -> it + 1)
      .xPer(1,1, TimeUnit.SECONDS)
      .limit(3)
      .map(seconds -> "hello!")
      .peek(System.out::println)
      .toList();
 System.out.println("time = " +(System.currentTimeMillis()-start));
 assertTrue("failed time was " + (System.currentTimeMillis()-start),System.currentTimeMillis()-start>1600);
}

代码示例来源:origin: aol/cyclops

@Test
public void xPerSecond() throws InterruptedException {
  Thread.sleep(500);
  long start = System.currentTimeMillis();
      iterate(1, it -> it + 1)
      .xPer(1,1, TimeUnit.SECONDS)
      .limit(3)
      .map(seconds -> "hello!")
      .peek(System.out::println)
      .toList();
 System.out.println("time = " +(System.currentTimeMillis()-start));
 assertTrue("failed time was " + (System.currentTimeMillis()-start),System.currentTimeMillis()-start>1600);
}

代码示例来源:origin: aol/cyclops

@Test
public void xPerSecond() throws InterruptedException {
  Thread.sleep(500);
  long start = System.currentTimeMillis();
      iterate(1, it -> it + 1)
      .xPer(1,1, TimeUnit.SECONDS)
      .limit(3)
      .map(seconds -> "hello!")
      .peek(System.out::println)
      .toList();
 System.out.println("time = " +(System.currentTimeMillis()-start));
 assertTrue("failed time was " + (System.currentTimeMillis()-start),System.currentTimeMillis()-start>1600);
}

代码示例来源:origin: aol/cyclops

@Test
public void xPerSecond() throws InterruptedException {
  for (int i = 0; i < 5; i++) {
    long start = System.currentTimeMillis();
    List<String> list = iterate(1, it -> it + 1)
      .xPer(1, 1, TimeUnit.SECONDS)
      .limit(3)
      .map(seconds -> "hello!")
      .peek(System.out::println)
      .toList();
    System.out.println("time = " + (System.currentTimeMillis() - start));
    assertTrue("failed time was " + (System.currentTimeMillis() - start) + " list " + list.size(), System.currentTimeMillis() - start > 1600);
  }
}

代码示例来源:origin: aol/cyclops

@Test
public void xPer(){
  System.out.println(of(1,2,3,4,5,6).xPer(6,1000,TimeUnit.NANOSECONDS).collect(Collectors.toList()));
  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));
}
@Test

代码示例来源:origin: aol/cyclops

@Test
public void xPerSecond() throws InterruptedException {
  Thread.sleep(500);
  long start = System.currentTimeMillis();
      iterate(1, it -> it + 1)
      .xPer(1,1, TimeUnit.SECONDS)
      .limit(3)
      .map(seconds -> "hello!")
      .peek(System.out::println)
      .to(Streamable::fromStream).toList();
 System.out.println("time = " +(System.currentTimeMillis()-start));
 assertTrue("failed time was " + (System.currentTimeMillis()-start),System.currentTimeMillis()-start>1600);
}

代码示例来源:origin: aol/cyclops

@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));
}
@Test

代码示例来源:origin: aol/cyclops

@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));
}
@Test

代码示例来源:origin: aol/cyclops

@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));
}
@Test

代码示例来源:origin: aol/cyclops

@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));
}
@Test

代码示例来源:origin: aol/cyclops

@Test
public void xPer(){
  SimpleTimer timer = new SimpleTimer();
  assertThat(of(1,2,3,4,5,6).xPer(6,100000000,TimeUnit.NANOSECONDS).to(Streamable::fromStream).collect(Collectors.toList()).size(),is(6));
  assertThat(timer.getElapsedNanoseconds(),lessThan(60000000l));
}
@Test

代码示例来源:origin: com.oath.cyclops/cyclops

/**
 * emit x elements per time period
 *
 * <pre>
 * {@code
 *  SimpleTimer timer = new SimpleTimer();
  assertThat(Streamable.of(1,2,3,4,5,6)
            .xPer(6,100000000,TimeUnit.NANOSECONDS)
            .collect(CyclopsCollectors.toList()).size(),is(6));
 * }
 * </pre>
 * @param x number of elements to emit
 * @param time period
 * @param t Time unit
 * @return Streamable that emits x elements per time period
 */
default ReactiveSeq<T> xPer(final int x, final long time, final TimeUnit t) {
  return this.stream().xPer(x, time, t);
}

代码示例来源:origin: com.oath.cyclops/cyclops

/**
 * emit x elements per time period
 *
 * <pre>
 * {@code
 *  SimpleTimer timer = new SimpleTimer();
  ReactiveSeq.of(1, 2, 3, 4, 5, 6)
        .xPer(6, 100000000, TimeUnit.NANOSECONDS)
        .collect(CyclopsCollectors.toList())
        .size()
  //6
 *
 * }
 * </pre>
 *
 * @param x
 *            number of elements to emit
 * @param time
 *            period
 * @param t
 *            Time unit
 * @return ReactiveSeq that emits x elements per time period
 */
default ReactiveSeq<T> xPer(final int x, final long time, final TimeUnit t) {
  return stream().xPer(x, time, t);
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法