Class

nl.grons.metrics.scala

Timer

Related Doc: package scala

Permalink

class Timer extends AnyRef

A Scala facade class for DropwizardTimer.

Features: * measure the execution duration of a block of code with time() * measure the time until a future is completed with timeFuture() * add an execution duration measurement as a side effect to a partial function with timePF() * direct access to the underlying timer with update(), timerContext(), count, max, etc.

Example usage:

class Example(val db: Db) extends Instrumented {
  private[this] val loadTimer = metrics.timer("load")

  def load(id: Long) = loadTimer.time {
    db.load(id)
  }
}
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Timer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Timer(metric: com.codahale.metrics.Timer)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def count: Long

    Permalink

    The number of durations recorded.

  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def fifteenMinuteRate: Double

    Permalink

    The fifteen-minute rate of timings.

  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def fiveMinuteRate: Double

    Permalink

    The five-minute rate of timings.

  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. def max: Long

    Permalink

    The longest recorded duration in nanoseconds.

  16. def mean: Double

    Permalink

    The arithmetic mean of all recorded durations in nanoseconds.

  17. def meanRate: Double

    Permalink

    The mean rate of timings.

  18. def min: Long

    Permalink

    The shortest recorded duration in nanoseconds.

  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. def oneMinuteRate: Double

    Permalink

    The one-minute rate of timings.

  23. def snapshot: Snapshot

    Permalink

    A snapshot of the values in the timer's sample.

  24. def stdDev: Double

    Permalink

    The standard deviation of all recorded durations.

  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. def time[A](f: ⇒ A): A

    Permalink

    Runs f, recording its duration, and returns its result.

  27. def timeFuture[A](future: ⇒ Future[A])(implicit context: ExecutionContext): Future[A]

    Permalink

    Measures 'now' up to the moment that the given future completes, then updates this timer with the measurement.

    Measures 'now' up to the moment that the given future completes, then updates this timer with the measurement.

    *Know what you measure*

    This method may measure more than is obvious. It measures: * the evaluation of the (by name) parameter future * in case the future is not yet completed: the delay until the constructed Future is scheduled in the given ExecutionContext * in case the future is not yet completed: the actual execution of the Future * the time it takes to schedule stopping the timer

    To only measure the Future execution time, please use use a timer in the code that is executed inside the Future.

    Example usage:

    class Example extends Instrumented {
      private[this] loadTimer = metrics.timer("loading")
    
      private def asyncFetchRows(): Future[Seq[Row]] = ...
    
      def loadStuffEventually(): Future[Seq[Row]] = loadTimer.timeFuture { asyncFetchRows() }
    }
    A

    future result type

    future

    the expression that results in a future

    context

    execution context

    returns

    the result of executing future

  28. def timePF[A, B](pf: PartialFunction[A, B]): PartialFunction[A, B]

    Permalink

    Converts partial function pf into a side-effecting partial function that times every invocation of pf for which it is defined.

    Converts partial function pf into a side-effecting partial function that times every invocation of pf for which it is defined. The result is passed unchanged.

    Example usage:

    class Example extends Instrumented {
      val isEven: PartialFunction[Int, String] = {
        case x if x % 2 == 0 => x+" is even"
      }
    
      val isEvenTimer = metrics.timer("isEven")
      val timedIsEven: PartialFunction[Int, String] = isEvenTimer.timePF(isEven)
    
      val sample = 1 to 10
      sample collect timedIsEven   // timer does 5 measurements
    }
  29. def timerContext(): Context

    Permalink

    A timing com.codahale.metrics.Timer.Context, which measures an elapsed time in nanoseconds.

  30. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  31. def update(duration: Long, unit: TimeUnit): Unit

    Permalink

    Adds a recorded duration.

  32. def update(duration: FiniteDuration): Unit

    Permalink

    Adds a recorded duration.

  33. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped