mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Return pairs for benchmark functions.
This commit is contained in:
parent
db1207ac04
commit
d37827ce93
1 changed files with 7 additions and 4 deletions
|
@ -1,12 +1,15 @@
|
||||||
package com.beust.kobalt.misc
|
package com.beust.kobalt.misc
|
||||||
|
|
||||||
fun benchmarkMillis(run: () -> Unit) : Long {
|
fun <T> benchmarkMillis(run: () -> T) : Pair<Long, T> {
|
||||||
val start = System.currentTimeMillis()
|
val start = System.currentTimeMillis()
|
||||||
run()
|
val result = run()
|
||||||
return System.currentTimeMillis() - start
|
return Pair(System.currentTimeMillis() - start, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun benchmarkSeconds(run: () -> Unit) = benchmarkMillis(run) / 1000
|
fun <T> benchmarkSeconds(run: () -> T) : Pair<Long, T> {
|
||||||
|
val result = benchmarkMillis(run)
|
||||||
|
return Pair(result.first / 1000, result.second)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue