Change constants for getting more stable benchmarks. (#2631)
This commit is contained in:
@@ -81,7 +81,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
val options = listOf(
|
||||
OptionDescriptor(ArgType.String(), "output", "o", "Output file"),
|
||||
OptionDescriptor(ArgType.Double(), "eps", "e", "Meaningful performance changes", "0.5"),
|
||||
OptionDescriptor(ArgType.Double(), "eps", "e", "Meaningful performance changes", "1.0"),
|
||||
OptionDescriptor(ArgType.Boolean(), "short", "s", "Show short version of report", "false"),
|
||||
OptionDescriptor(ArgType.Choice(listOf("text", "html", "teamcity", "statistics")),
|
||||
"renders", "r", "Renders for showing information", "text", isMultiple = true),
|
||||
|
||||
@@ -71,10 +71,11 @@ data class MeanVarianceBenchmark(val meanBenchmark: BenchmarkResult, val varianc
|
||||
|
||||
}
|
||||
|
||||
fun geometricMean(values: List<Double>) = values.map { it.pow(1.0 / values.size) }.reduce { a, b -> a * b }
|
||||
fun geometricMean(values: List<Double>, totalNumber: Int? = null) =
|
||||
values.map { it.pow(1.0 / (totalNumber ?: values.size)) }.reduce { a, b -> a * b }
|
||||
|
||||
fun computeMeanVariance(samples: List<Double>): MeanVariance {
|
||||
val zStar = 1.96 // Critical point for 90% confidence of normal distribution.
|
||||
val zStar = 1.67 // Critical point for 90% confidence of normal distribution.
|
||||
val mean = samples.sum() / samples.size
|
||||
val variance = samples.indices.sumByDouble { (samples[it] - mean) * (samples[it] - mean) } / samples.size
|
||||
val confidenceInterval = sqrt(variance / samples.size) * zStar
|
||||
|
||||
+2
-2
@@ -142,12 +142,12 @@ class SummaryBenchmarksReport (val currentReport: BenchmarksReport,
|
||||
return 0.0
|
||||
var percentsList = bucket.values.map { it.first.mean }
|
||||
return if (percentsList.first() > 0.0) {
|
||||
geometricMean(percentsList)
|
||||
geometricMean(percentsList, benchmarksNumber)
|
||||
} else {
|
||||
// Geometric mean can be counted on positive numbers.
|
||||
val precision = abs(getMaximumChange(bucket)) + 1
|
||||
percentsList = percentsList.map { it + precision }
|
||||
geometricMean(percentsList) - precision
|
||||
geometricMean(percentsList, benchmarksNumber) - precision
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class AnalyzerTests {
|
||||
val numbers = listOf(10.1, 10.2, 10.3)
|
||||
val value = computeMeanVariance(numbers)
|
||||
val expectedMean = 10.2
|
||||
val expectedVariance = 0.092395
|
||||
val expectedVariance = 0.12539360253
|
||||
assertTrue(abs(value.mean - expectedMean) < eps)
|
||||
assertTrue(abs(value.variance - expectedVariance) < eps)
|
||||
}
|
||||
@@ -76,4 +76,4 @@ class AnalyzerTests {
|
||||
assertTrue(abs(ratio.mean - expectedMean) < eps)
|
||||
assertTrue(abs(ratio.variance - expectedVariance) < eps)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user