Stopwatch

class Stopwatch(val ticker: Ticker, immediately: Boolean)

Simple Stopwatch

Since

3.0.0

Companion
object
class Object
trait Matchable
class Any

Value members

Constructors

def this(immediately: Boolean)

Concrete methods

def elapsedMillis: Long

Returns the current elapsed time shown on this stopwatch, expressed in milliseconds, with any fraction rounded down. This is identical to <code>elapsedTime(TimeUnit.MILLISECONDS</code>.

Returns the current elapsed time shown on this stopwatch, expressed in milliseconds, with any fraction rounded down. This is identical to <code>elapsedTime(TimeUnit.MILLISECONDS</code>.

def elapsedTime(desiredUnit: TimeUnit): Long

Returns the current elapsed time shown on this stopwatch, expressed in the desired time unit, with any fraction rounded down.

Returns the current elapsed time shown on this stopwatch, expressed in the desired time unit, with any fraction rounded down.

Note that the overhead of measurement can be more than a microsecond, so it is generally not useful to specify [[TimeUnit#NANOSECONDS]] precision here.

Sets the elapsed time for this stopwatch to zero, and places it in a stopped state.

Sets the elapsed time for this stopwatch to zero, and places it in a stopped state.

Returns

this <code>Stopwatch</code> instance

Starts the stopwatch.

Starts the stopwatch.

Returns

this <code>Stopwatch</code> instance

Throws
IllegalStateException

if the stopwatch is already running.

def stop(): Stopwatch

Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this point.

Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this point.

Returns

this <code>Stopwatch</code> instance

Throws
IllegalStateException

if the stopwatch is already stopped.

override def toString: String

Returns a string representation of the current elapsed time; equivalent to <code>toString(4)</code> (four significant figures).

Returns a string representation of the current elapsed time; equivalent to <code>toString(4)</code> (four significant figures).

Definition Classes
Any

Concrete fields

var running: Boolean