Files
postgres-json/src/main/kotlin/fr/postgresjson/stopwatch/Stopwatch.kt

9 lines
258 B
Kotlin

package fr.postgresjson.stopwatch
fun <T> elapse(callback: (start: Long) -> T, after: (elapse: Long) -> Unit): T {
val start = System.currentTimeMillis()
val result = callback(start)
after(System.currentTimeMillis() - start)
return result
}