io.opencensus.common.Duration.fromMillis()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(111)

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

Duration.fromMillis介绍

[英]Creates a new Duration from given milliseconds.
[中]从给定的毫秒创建一个新的持续时间。

代码示例

代码示例来源:origin: census-instrumentation/opencensus-java

private IntervalMutableViewData(View view, Timestamp start) {
 super(view);
 Duration totalDuration = ((View.AggregationWindow.Interval) view.getWindow()).getDuration();
 this.totalDuration = totalDuration;
 this.bucketDuration = Duration.fromMillis(totalDuration.toMillis() / N);
 // When initializing. add N empty buckets prior to the start timestamp of this
 // IntervalMutableViewData, so that the last bucket will be the current one in effect.
 shiftBucketList(N + 1, start);
}

代码示例来源:origin: io.opencensus/opencensus-impl-core

private IntervalMutableViewData(View view, Timestamp start) {
 super(view);
 Duration totalDuration = ((View.AggregationWindow.Interval) view.getWindow()).getDuration();
 this.totalDuration = totalDuration;
 this.bucketDuration = Duration.fromMillis(totalDuration.toMillis() / N);
 // When initializing. add N empty buckets prior to the start timestamp of this
 // IntervalMutableViewData, so that the last bucket will be the current one in effect.
 shiftBucketList(N + 1, start);
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void testDurationFromMillisNegative() {
 assertThat(Duration.fromMillis(-1)).isEqualTo(Duration.create(0, -1000000));
 assertThat(Duration.fromMillis(-999)).isEqualTo(Duration.create(0, -999000000));
 assertThat(Duration.fromMillis(-1000)).isEqualTo(Duration.create(-1, 0));
 assertThat(Duration.fromMillis(-3456)).isEqualTo(Duration.create(-3, -456000000));
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void testDurationFromMillis() {
 assertThat(Duration.fromMillis(0)).isEqualTo(Duration.create(0, 0));
 assertThat(Duration.fromMillis(987)).isEqualTo(Duration.create(0, 987000000));
 assertThat(Duration.fromMillis(3456)).isEqualTo(Duration.create(3, 456000000));
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void fromMillis_TooLow() {
 thrown.expect(IllegalArgumentException.class);
 thrown.expectMessage("'seconds' is less than minimum (-315576000000): -315576000001");
 Duration.fromMillis(-315576000001000L);
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void fromMillis_TooHigh() {
 thrown.expect(IllegalArgumentException.class);
 thrown.expectMessage("'seconds' is greater than maximum (315576000000): 315576000001");
 Duration.fromMillis(315576000001000L);
}

相关文章