elapsedNow

abstract fun elapsedNow(): Duration(source)

Returns the amount of time passed from this mark measured with the time source from which this mark was taken.

Note that the value returned by this function can change on subsequent invocations.

The value returned by this function may be infinitely large (in terms of Duration.isInfinite).

Depending on monotonicity guarantees of a TimeSource from which a TimeMark was obtained, subsequence calls may return non-increasing (or even negative) Duration values. Consult with a documentation of a particular TimeSource implementation for more details about monotonicity guarantees.

Since Kotlin

1.9

Throws

an implementation may throw if calculating the elapsed time involves adding a positive infinite duration to an infinitely distant past time mark or a negative infinite duration to an infinitely distant future time mark.