AbstractLongClock

Common
JVM
JS
Native
1.3
abstract class AbstractLongClock : Clock

An abstract class used to implement clocks that return their readings as Long values in the specified unit.

Constructors

Common
JVM
JS
Native
1.0

<init>

An abstract class used to implement clocks that return their readings as Long values in the specified unit.

AbstractLongClock(unit: DurationUnit)

Properties

Common
JVM
JS
Native
1.0

unit

The unit in which this clock readings are expressed.

val unit: DurationUnit

Functions

Common
JVM
JS
Native
1.0

markNow

Marks a time point on this clock.

open fun markNow(): ClockMark
Common
JVM
JS
Native
1.0

read

This protected method should be overridden to return the current reading of the clock expressed as a Long number in the unit specified by the unit property.

abstract fun read(): Long

Extension Functions

Common
JVM
JS
Native
1.3

measureTime

Executes the given function block and returns the duration of elapsed time interval.

fun Clock.measureTime(block: () -> Unit): Duration
Common
JVM
JS
Native
1.3

measureTimedValue

Executes the given block and returns an instance of TimedValue class, containing both the result of function execution and the duration of elapsed time interval.

fun <T> Clock.measureTimedValue(
    block: () -> T
): TimedValue<T>

Inheritors

MonoClock

The most precise clock available in the platform.

Common
JS
1.3
object MonoClock : Clock
JVM
Native
1.3
object MonoClock : AbstractLongClock, Clock
Common
JVM
JS
Native
1.3

TestClock

A clock that has programmatically updatable readings. It is useful as a predictable source of time in tests.

class TestClock : AbstractLongClock