当前位置: 首页>>代码示例>>Java>>正文


Java Timer.record方法代码示例

本文整理汇总了Java中io.micrometer.core.instrument.Timer.record方法的典型用法代码示例。如果您正苦于以下问题:Java Timer.record方法的具体用法?Java Timer.record怎么用?Java Timer.record使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.micrometer.core.instrument.Timer的用法示例。


在下文中一共展示了Timer.record方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: record

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
@DisplayName("total time and count are preserved for a single timing")
default void record(MeterRegistry registry) {
    Timer t = registry.timer("myTimer");
    t.record(42, TimeUnit.MILLISECONDS);
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, t.count()),
            () -> assertEquals(42, t.totalTime(TimeUnit.MILLISECONDS), 1.0e-12));
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:11,代码来源:TimerTest.java

示例2: recordDuration

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
@DisplayName("record durations")
default void recordDuration(MeterRegistry registry) {
    Timer t = registry.timer("myTimer");
    t.record(Duration.ofMillis(42));
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, t.count()),
        () -> assertEquals(42, t.totalTime(TimeUnit.MILLISECONDS), 1.0e-12));
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:11,代码来源:TimerTest.java

示例3: recordNegative

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
@DisplayName("negative times are discarded by the Timer")
default void recordNegative(MeterRegistry registry) {
    Timer t = registry.timer("myTimer");
    t.record(-42, TimeUnit.MILLISECONDS);

    assertAll(() -> assertEquals(0L, t.count()),
            () -> assertEquals(0, t.totalTime(TimeUnit.NANOSECONDS), 1.0e-12));
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:10,代码来源:TimerTest.java

示例4: recordZero

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
@DisplayName("zero times contribute to the count of overall events but do not add to total time")
default void recordZero(MeterRegistry registry) {
    Timer t = registry.timer("myTimer");
    t.record(0, TimeUnit.MILLISECONDS);
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, t.count()),
            () -> assertEquals(0L, t.totalTime(TimeUnit.NANOSECONDS)));
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:11,代码来源:TimerTest.java

示例5: recordWithRunnable

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
@DisplayName("record a runnable task")
default void recordWithRunnable(MeterRegistry registry) throws Exception {
    Timer t = registry.timer("myTimer");

    try {
        t.record(() -> clock(registry).add(10, TimeUnit.NANOSECONDS));
        clock(registry).add(step());
    } finally {
        assertAll(() -> assertEquals(1L, t.count()),
                () -> assertEquals(10, t.totalTime(TimeUnit.NANOSECONDS) ,1.0e-12));
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:14,代码来源:TimerTest.java

示例6: recordMax

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
default void recordMax(MeterRegistry registry) {
    Timer timer = registry.timer("my.timer");
    timer.record(10, TimeUnit.MILLISECONDS);
    timer.record(1, TimeUnit.SECONDS);

    clock(registry).add(step()); // for Atlas, which is step rather than ring-buffer based
    assertThat(timer.max(TimeUnit.SECONDS)).isEqualTo(1);
    assertThat(timer.max(TimeUnit.MILLISECONDS)).isEqualTo(1000);

    clock(registry).add(Duration.ofMillis(step().toMillis() * HistogramConfig.DEFAULT.getHistogramBufferLength()));
    assertThat(timer.max(TimeUnit.SECONDS)).isEqualTo(0);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:14,代码来源:TimerTest.java

示例7: recordThrowable

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
private Object recordThrowable(Timer timer, ThrowableCallable f) throws Throwable {
    long start = registry.config().clock().monotonicTime();
    try {
        return f.call();
    } finally {
        timer.record(registry.config().clock().monotonicTime() - start, TimeUnit.NANOSECONDS);
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:ScheduledMethodMetrics.java

示例8: timerMax

import io.micrometer.core.instrument.Timer; //导入方法依赖的package包/类
@Test
void timerMax() {
    AtlasConfig atlasConfig = k -> null;
    AtlasMeterRegistry registry = new AtlasMeterRegistry(atlasConfig, new MockClock());
    Timer timer = registry.timer("timer");

    timer.record(1, TimeUnit.SECONDS);
    clock(registry).add(atlasConfig.step());
    assertThat(timer.max(TimeUnit.MILLISECONDS)).isEqualTo(1000);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:11,代码来源:SpectatorTimerTest.java


注:本文中的io.micrometer.core.instrument.Timer.record方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。