TimeSource

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.

Since Kotlin

1.9

See also

Inheritors

Types

Link copied to clipboard
object Companion
Since Kotlin 1.9
Link copied to clipboard

The most precise time source available in the platform.

Since Kotlin 1.9
Link copied to clipboard

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

Since Kotlin 1.9

Functions

Link copied to clipboard
abstract fun markNow(): TimeMark

Marks a point in time on this time source.

Since Kotlin 1.9
Link copied to clipboard
inline fun TimeSource.measureTime(block: () -> Unit): Duration

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

Since Kotlin 1.9
Link copied to clipboard
inline fun <T> TimeSource.measureTimedValue(block: () -> T): TimedValue<T>

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.

Since Kotlin 1.9