report.donut.performance.PerformanceSupport.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of donut Show documentation
Show all versions of donut Show documentation
Donut - Automated Testing Reporting Tool
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
}