measure

inline fun <T> measure(block: () -> T): T

Runs block while the stopwatch is running and returns the block's result.

The stopwatch is started before the block and stopped afterwards, even when the block throws. A stopwatch that was already running keeps its current segment and is stopped when the block completes.