Skip to content

Commit e0a1b3c

Browse files
committed
Add params to benchmark report
1 parent ea1e5ba commit e0a1b3c

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

runtime/commonMain/src/org/jetbrains/gradle/benchmarks/BenchmarkReporter.kt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@ package org.jetbrains.gradle.benchmarks
33
expect fun saveReport(reportFile: String?, results: Collection<ReportBenchmarkResult>)
44

55
fun formatJson(results: Collection<ReportBenchmarkResult>) =
6-
results.joinToString(",", prefix = "[", postfix = "\n]") {
6+
results.joinToString(",", prefix = "[", postfix = "\n]") { result ->
77
"""
88
{
9-
"benchmark" : "${it.benchmark.name}",
10-
"mode" : "${it.config.mode.toText()}",
11-
"warmupIterations" : ${it.config.warmups},
12-
"warmupTime" : "${it.config.iterationTime} ${it.config.iterationTimeUnit.toText()}",
13-
"measurementIterations" : ${it.config.iterations},
14-
"measurementTime" : "${it.config.iterationTime} ${it.config.iterationTimeUnit.toText()}",
9+
"benchmark" : "${result.benchmark.name}",
10+
"mode" : "${result.config.mode.toText()}",
11+
"warmupIterations" : ${result.config.warmups},
12+
"warmupTime" : "${result.config.iterationTime} ${result.config.iterationTimeUnit.toText()}",
13+
"measurementIterations" : ${result.config.iterations},
14+
"measurementTime" : "${result.config.iterationTime} ${result.config.iterationTimeUnit.toText()}",
15+
"params" : {
16+
${result.params.entries.joinToString(separator = ",\n ") {
17+
"\"${it.key}\" : \"${it.value}\""
18+
}}
19+
},
1520
"primaryMetric" : {
16-
"score": ${it.score},
17-
"scoreError": ${it.error},
21+
"score": ${result.score},
22+
"scoreError": ${result.error},
1823
"scoreConfidence" : [
19-
${it.confidence.first},
20-
${it.confidence.second}
24+
${result.confidence.first},
25+
${result.confidence.second}
2126
],
2227
"scorePercentiles" : {
23-
${it.percentiles.entries.joinToString(separator = ",\n ") {
28+
${result.percentiles.entries.joinToString(separator = ",\n ") {
2429
"\"${it.key.format(2)}\" : ${it.value}"
2530
}}
2631
},
27-
"scoreUnit" : "${unitText(it.config.mode, it.config.outputTimeUnit)}",
32+
"scoreUnit" : "${unitText(result.config.mode, result.config.outputTimeUnit)}",
2833
"rawData" : [
29-
${it.values.joinToString(
34+
${result.values.joinToString(
3035
prefix = "[\n ",
3136
postfix = "\n ]",
3237
separator = ",\n "

runtime/commonMain/src/org/jetbrains/gradle/benchmarks/ReportBenchmarkResult.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.jetbrains.gradle.benchmarks
33
class ReportBenchmarkResult(
44
val config: BenchmarkConfiguration,
55
val benchmark: BenchmarkDescriptor<*>,
6+
val params: Map<String, String>,
67
val score: Double,
78
val error: Double,
89
val confidence: Pair<Double, Double>,

runtime/commonMain/src/org/jetbrains/gradle/benchmarks/ReportBenchmarksStatistics.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ class ReportBenchmarksStatistics(values: DoubleArray) {
5151
}
5252

5353
companion object {
54-
fun createResult(benchmark: BenchmarkDescriptor<*>, config: BenchmarkConfiguration, samples: DoubleArray): ReportBenchmarkResult {
54+
fun createResult(
55+
benchmark: BenchmarkDescriptor<*>,
56+
params: Map<String, String>,
57+
config: BenchmarkConfiguration,
58+
samples: DoubleArray
59+
): ReportBenchmarkResult {
5560
val statistics = ReportBenchmarksStatistics(samples)
5661
val score = statistics.mean()
5762
val errorMargin = 1.96 * (statistics.standardDeviation() / sqrt(samples.size.toDouble()))
@@ -70,6 +75,7 @@ class ReportBenchmarksStatistics(values: DoubleArray) {
7075
return ReportBenchmarkResult(
7176
config,
7277
benchmark,
78+
params,
7379
score,
7480
errorMargin,
7581
(score - errorMargin) to (score + errorMargin),

runtime/jsMain/src/org/jetbrains/gradle/benchmarks/js/JsExecutor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class JsExecutor(name: String, @Suppress("UNUSED_PARAMETER") dummy_args: Array<o
8888
nanos.nanosToSample(config.mode, config.outputTimeUnit)
8989
}
9090
.toDoubleArray()
91-
val result = ReportBenchmarksStatistics.createResult(benchmark, config, samples)
91+
val result = ReportBenchmarksStatistics.createResult(benchmark, params, config, samples)
9292
val message = with(result) {
9393
" ~ ${score.sampleToText(
9494
config.mode,

runtime/nativeMain/src/org/jetbrains/gradle/benchmarks/native/NativeExecutor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class NativeExecutor(name: String, args: Array<out String>) : SuiteExecutor(name
4444
}
4545

4646
if (exception == null) {
47-
val result = ReportBenchmarksStatistics.createResult(benchmark, config, samples)
47+
val result = ReportBenchmarksStatistics.createResult(benchmark, params, config, samples)
4848
val message = with(result) {
4949
// TODO: metric
5050
" ~ ${score.sampleToText(

0 commit comments

Comments
 (0)