Add measureTimeMillisWithResult function to addToStdlib
This commit is contained in:
@@ -125,3 +125,9 @@ inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
|
||||
inline fun <T, C : Collection<T>, O> C.ifNotEmpty(body: C.() -> O?): O? = if (isNotEmpty()) this.body() else null
|
||||
|
||||
inline fun <T, O> Array<out T>.ifNotEmpty(body: Array<out T>.() -> O?): O? = if (isNotEmpty()) this.body() else null
|
||||
|
||||
inline fun <T> measureTimeMillisWithResult(block: () -> T) : Pair<Long, T> {
|
||||
val start = System.currentTimeMillis()
|
||||
val result = block()
|
||||
return Pair(System.currentTimeMillis() - start, result)
|
||||
}
|
||||
Reference in New Issue
Block a user