Skip to content

Commit

Permalink
Print result coeff as double
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinAnisimov committed Aug 4, 2017
1 parent b4660d0 commit 8b7cad3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions performance/src/main/kotlin/org/jetbrains/ring/launcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ class Launcher(val numWarmIterations: Int, val numMeasureIterations: Int) {
//-------------------------------------------------------------------------//

fun printResults() {
var total = 0L
var total = 0.0
results.forEach {
val normaTime = NormaResults[it.key]
val norma = it.value / normaTime!!
val norma = it.value.toDouble() / normaTime!!.toDouble()
val niceName = it.key.padEnd(50, ' ')
val niceNorma = norma.toString().padStart(10, ' ')
val niceNorma = norma.toString(2).padStart(10, ' ')
println("$niceName : $niceNorma")

total += norma
}
val average = total / results.size
println("\nRingAverage: $average")
println("\nRingAverage: ${average.toString(2)}")
}

//-------------------------------------------------------------------------//
Expand Down Expand Up @@ -416,4 +416,15 @@ class Launcher(val numWarmIterations: Int, val numMeasureIterations: Int) {
results["WithIndicies.withIndicies"] = launch(benchmark::withIndicies)
results["WithIndicies.withIndiciesManual"] = launch(benchmark::withIndiciesManual)
}

//-----------------------------------------------------------------------------//

fun Double.toString(n: Int): String {
val str = this.toString()
val len = str.length
val pointIdx = str.indexOf('.')
val dropCnt = len - pointIdx - n - 1
if (dropCnt < 1) return str
return str.dropLast(dropCnt)
}
}

0 comments on commit 8b7cad3

Please sign in to comment.