TimeSource

Common
JVM
JS
Native
1.9
interface TimeSource
(source)

A source of time for measuring time intervals.

The only operation provided by the time source is markNow. It returns a TimeMark, which can be used to query the elapsed time later.

See Also

measureTime

measureTimedValue

Types

Common
JVM
JS
Native
1.0

Monotonic

The most precise time source available in the platform.

object Monotonic : WithComparableMarks
Common
JVM
JS
Native
1.9

WithComparableMarks

A TimeSource that returns time marks that can be compared for difference with each other.

interface WithComparableMarks : TimeSource

Functions

Common
JVM
JS
Native
1.0

markNow

Marks a point in time on this time source.

abstract fun markNow(): TimeMark

Extension Functions

Common
JVM
JS
Native
1.9

measureTime

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

fun TimeSource.measureTime(block: () -> Unit): Duration
Common
JVM
JS
Native
1.9

measureTimedValue

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

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