Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ScheduledReporter convertDurations precision #1115

Merged

Conversation

kyeah
Copy link
Contributor

@kyeah kyeah commented Mar 26, 2017

Hello! This was something I noticed while testing metric conversions recently.

For a precision test like this:

@Test
public void shouldConvertDurationToMillisecondsPrecisely() {
  assertEquals(2.0E-5, reporter.convertDuration(20), 0.0);
}

The current implementation will fail:

java.lang.AssertionError: 
Expected :2.0E-5
Actual   :1.9999999999999998E-5

However, if we perform the division directly on given durations, the test will pass.

I don't believe this change degrades the precision for other inputs, but happy to hear otherwise and backpedal :)

@jplock jplock modified the milestones: 3.2.2, 3.2.3 Mar 26, 2017
@arteam arteam merged commit 8b2277f into dropwizard:3.2-development Apr 7, 2017
@arteam
Copy link
Member

arteam commented Apr 7, 2017

Thank you. I think it should be the same from the math's point of view, but more precise, because we do only one division, instead of division and multiplying.

azagniotov added a commit to azagniotov/codahale-aggregated-metrics-cloudwatch-reporter that referenced this pull request Aug 20, 2017
- Upgraded Metrics to 'v3.2.3' due to dropwizard/metrics#1115
- Upgraded AWS Java SDK to 'v1.11.179'
- Added more tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants