All Downloads are FREE. Search and download functionalities are using the official Maven repository.

report.donut.performance.PerformanceSupport.scala Maven / Gradle / Ivy

The newest version!
package report.donut.performance

import com.codahale.metrics.MetricRegistry
import report.donut.log.Log

import scala.concurrent.duration._

trait PerformanceSupport extends Log {
  def registry: MetricRegistry = PerformanceSupport.registry

  def timed[T](id: String, msg: String)(thunk: => T): T = {
    val timer = registry.timer(id).time
    val result = thunk
    val duration = timer.stop.nanos
    log.debug(s"$msg in ${duration.toMillis}ms")
    result
  }
}

object PerformanceSupport {
  val registry = new MetricRegistry
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy