Skip to content

Instantly share code, notes, and snippets.

@aludwiko
Last active January 30, 2018 15:16
Show Gist options
  • Select an option

  • Save aludwiko/4b5b7e23676f65dd962d4d16c57e1b62 to your computer and use it in GitHub Desktop.

Select an option

Save aludwiko/4b5b7e23676f65dd962d4d16c57e1b62 to your computer and use it in GitHub Desktop.
Dropwizard Metrics
object DropWizardTest extends App {
val random = Random
val times =
//normal behavior
(1 to 100000).map(_ => random.nextInt(100)) ++
//standard peacks
(1 to 100).map(_ => 1000) ++
//very high peacks
(1 to 10).map(_ => 10000)
//print histogram for the same data set
(1 to 1).foreach(_ => printHdrHistogram(times))
def printHistogram(times: Seq[Int]) = {
val timer = new Timer
times.map(time => timer.update(time, TimeUnit.NANOSECONDS))
val snapshot = timer.getSnapshot
println("-----------")
printf("75: %f\n", snapshot.get75thPercentile())
printf("95: %f\n", snapshot.get95thPercentile())
printf("99: %f\n", snapshot.get99thPercentile())
printf("99.9: %f\n", snapshot.get999thPercentile())
printf("max: %d\n", snapshot.getMax)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment