mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -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
|
||||
|
||||
fun benchmarkMillis(run: () -> Unit) : Long {
|
||||
fun <T> benchmarkMillis(run: () -> T) : Pair<Long, T> {
|
||||
val start = System.currentTimeMillis()
|
||||
run()
|
||||
return System.currentTimeMillis() - start
|
||||
val result = run()
|
||||
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