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) } }
- Alphabetic
- By Inheritance
- Timer
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Timer(metric: com.codahale.metrics.Timer)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
count: Long
The number of durations recorded.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
fifteenMinuteRate: Double
The fifteen-minute rate of timings.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
fiveMinuteRate: Double
The five-minute rate of timings.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
max: Long
The longest recorded duration in nanoseconds.
-
def
mean: Double
The arithmetic mean of all recorded durations in nanoseconds.
-
def
meanRate: Double
The mean rate of timings.
-
def
min: Long
The shortest recorded duration in nanoseconds.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
oneMinuteRate: Double
The one-minute rate of timings.
-
def
snapshot: Snapshot
A snapshot of the values in the timer's sample.
-
def
stdDev: Double
The standard deviation of all recorded durations.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
time[A](f: ⇒ A): A
Runs f, recording its duration, and returns its result.
-
def
timeFuture[A](future: ⇒ Future[A])(implicit context: ExecutionContext): Future[A]
Measures 'now' up to the moment that the given
futurecompletes, then updates this timer with the measurement.Measures 'now' up to the moment that the given
futurecompletes, 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 givenExecutionContext* in case the future is not yet completed: the actual execution of the Future * the time it takes to schedule stopping the timerTo 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
-
def
timePF[A, B](pf: PartialFunction[A, B]): PartialFunction[A, B]
Converts partial function
pfinto a side-effecting partial function that times every invocation ofpffor which it is defined.Converts partial function
pfinto a side-effecting partial function that times every invocation ofpffor 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 }
-
def
timerContext(): Context
A timing com.codahale.metrics.Timer.Context, which measures an elapsed time in nanoseconds.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
update(duration: Long, unit: TimeUnit): Unit
Adds a recorded duration.
-
def
update(duration: FiniteDuration): Unit
Adds a recorded duration.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )