Package-level declarations

API for measuring time intervals and calculating durations.

For more information, see our Time measurement guide.

API for measuring time intervals and calculating durations.

For more information, see our Time measurement guide.

API for measuring time intervals and calculating durations.

For more information, see our Time measurement guide.

API for measuring time intervals and calculating durations.

For more information, see our Time measurement guide.

API for measuring time intervals and calculating durations.

For more information, see our Time measurement guide.

API for measuring time intervals and calculating durations.

For more information, see our Time measurement guide.

Types

Link copied to clipboard

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

Since Kotlin 1.3
Link copied to clipboard

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

Since Kotlin 1.9
Link copied to clipboard

A TimeMark that can be compared for difference with other time marks obtained from the same TimeSource.WithComparableMarks time source.

Since Kotlin 1.9
Link copied to clipboard

Represents the amount of time one instant of time is away from another instant.

Since Kotlin 1.6
Link copied to clipboard

The list of possible time measurement units, in which a duration can be expressed.

Since Kotlin 1.6
Since Kotlin 1.6
Since Kotlin 1.6
Since Kotlin 1.6
Since Kotlin 1.8
Since Kotlin 1.8
Link copied to clipboard

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

Since Kotlin 1.9
Link copied to clipboard
data class TimedValue<T>(val value: T, val duration: Duration)

Data class representing a result of executing an action, along with the duration of the elapsed time interval.

Since Kotlin 1.9
Link copied to clipboard
interface TimeMark

Represents a time point notched on a particular TimeSource. Remains bound to the time source it was taken from and allows querying for the duration of time elapsed from that point (see the function elapsedNow).

Since Kotlin 1.9
Link copied to clipboard
interface TimeSource

A source of time for measuring time intervals.

Since Kotlin 1.9

Functions

Link copied to clipboard
inline fun measureTime(block: () -> Unit): Duration

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

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

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

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

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

Since Kotlin 1.9
Link copied to clipboard
inline fun <T> TimeSource.measureTimedValue(block: () -> T): TimedValue<T>
inline fun <T> TimeSource.Monotonic.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 the elapsed time interval.

Since Kotlin 1.9
Link copied to clipboard
inline operator fun Double.times(duration: Duration): Duration
inline operator fun Int.times(duration: Duration): Duration

Returns a duration whose value is the specified duration value multiplied by this number.

Since Kotlin 1.6
Link copied to clipboard

Returns a Duration equal to this Double number of the specified unit.

Since Kotlin 1.6

Returns a Duration equal to this Int number of the specified unit.

Since Kotlin 1.6

Returns a Duration equal to this Long number of the specified unit.

Since Kotlin 1.6
Link copied to clipboard

Converts this java.util.concurrent.TimeUnit enum value to the corresponding kotlin.time.DurationUnit value.

Since Kotlin 1.8
Link copied to clipboard

Converts kotlin.time.Duration value to java.time.Duration value.

Since Kotlin 1.6
Link copied to clipboard

Converts java.time.Duration value to kotlin.time.Duration value.

Since Kotlin 1.6
Link copied to clipboard

Converts this kotlin.time.DurationUnit enum value to the corresponding java.util.concurrent.TimeUnit value.

Since Kotlin 1.8