Skip to content

Commit

Permalink
Merge branch '1.0.x' into 1.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Feb 13, 2019
2 parents 429d3c6 + 12f9051 commit 414295f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public long getMax() {
@Override
public double getMean() {
double count = count();
return count == 0 ? 0 : totalTime(baseTimeUnit()) / count;
// This return value is expected to be in nanoseconds, for example in JmxReporter.JmxTimer.
return count == 0 ? 0 : totalTime(TimeUnit.NANOSECONDS) / count;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ void totalTimeWhenStateObjectChangedToNullShouldWorkWithChangedTimeUnit() {
assertThat(functionTimer.totalTime(TimeUnit.SECONDS)).isEqualTo(1d);
}

@Test
void getDropwizardMeterGetSnapshotGetMeanShouldReturnNanoseconds() {
DropwizardFunctionTimer functionTimer = new DropwizardFunctionTimer(
null, new MockClock(), new Object(), (o) -> 1L, (o) -> 1d, TimeUnit.SECONDS, TimeUnit.SECONDS);
assertThat(functionTimer.getDropwizardMeter().getSnapshot().getMean()).isEqualTo(1000_000_000d);
}

}

0 comments on commit 414295f

Please sign in to comment.