Commit d003bd87 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

benchmark MetricFactory#get_metric

parent f6f735d8
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -10,6 +10,13 @@ package com.fnordmetric.enterprise
object Benchmark {

  def run : Unit = {

    print_title("MetricFactory#get_metric")
    for (n <- List(10000, 50000, 100000))
      for (t <- List(1, 16, 64))
        bm_metric_factory(n, t)


    print_title("Metric#sample")
    for (n <- List(200000, 1000000, 5000000))
      for (t <- List(1, 4, 16))
@@ -35,6 +42,20 @@ object Benchmark {
      })))


  private def bm_metric_factory(metrics: Int, threads: Int) : Unit =
    print_res(metrics + " metrics, " + threads + " thread(s)",
      mean_with_preheat(50, 10, (() => {
        measure(() => {
          in_parallel(threads, (() => {
            for (x <- (0 to 100))
              MetricFactory.get_metric(MetricKey(
                "benchmark-metric" + (scala.math.random * metrics).toInt,
                "sum", 1.toLong))
          }))
        }) / 100
      })))


  private def measure(proc: => Function0[Unit]) : Long = {
    val tstart = FnordMetric.now
    proc()
@@ -63,7 +84,7 @@ object Benchmark {

  // HACK !!! ;)
  private def print_title(title: String) =
    println(title + "\n" +
    println("\n\n" + title + "\n" +
      (("" /: (1 to (title.length)))((m,c) => m + "=")) + "\n")

}