Print result coeff as double
This commit is contained in:
committed by
KonstantinAnisimov
parent
b4660d03a1
commit
8b7cad339e
@@ -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)}")
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user