W3cubDocs

/Kotlin

TimeSource

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalTime interface TimeSource

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

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Monotonic

The most precise time source available in the platform.

object Monotonic : TimeSource

Functions

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

markNow

Marks a point in time on this time source.

abstract fun markNow(): TimeMark

Extension Functions

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)

measureTime

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

fun TimeSource.measureTime(block: () -> Unit): Duration
Platform and version requirements: JVM (1.3), JS (1.3), 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> TimeSource.measureTimedValue(
    block: () -> T
): TimedValue<T>

Inheritors

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)

AbstractDoubleTimeSource

An abstract class used to implement time sources that return their readings as Double values in the specified unit.

abstract class AbstractDoubleTimeSource : TimeSource
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)

AbstractLongTimeSource

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

abstract class AbstractLongTimeSource : TimeSource

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.time/-time-source/index.html