changeset 403:3e30ac7a685c

JSON output should also include score percentiles.
author shade
date Tue, 18 Feb 2014 00:26:22 +0400
parents 0a7337dda90b
children 60aa6255909a
files jmh-core/src/main/java/org/openjdk/jmh/output/results/JSONResultFormat.java jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.json
diffstat 2 files changed, 201 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/results/JSONResultFormat.java	Mon Feb 17 23:47:05 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/results/JSONResultFormat.java	Tue Feb 18 00:26:22 2014 +0400
@@ -28,6 +28,7 @@
 import org.openjdk.jmh.logic.results.Result;
 import org.openjdk.jmh.logic.results.RunResult;
 import org.openjdk.jmh.runner.BenchmarkRecord;
+import org.openjdk.jmh.util.internal.Statistics;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -74,6 +75,7 @@
                 pw.println("\"score\" : " + emit(runResult.getPrimaryResult().getScore()) + ",");
                 pw.println("\"scoreError\" : " + emit(runResult.getPrimaryResult().getStatistics().getMeanErrorAt(0.999)) + ",");
                 pw.println("\"scoreConfidence\" : " + emit(runResult.getPrimaryResult().getStatistics().getConfidenceIntervalAt(0.999)) + ",");
+                pw.println(emitPercentiles(runResult.getPrimaryResult().getStatistics()));
                 pw.println("\"scoreUnit\" : \"" + runResult.getPrimaryResult().getScoreUnit() + "\",");
                 pw.println("\"rawData\" :");
 
@@ -99,6 +101,7 @@
                     sb.append("\"score\" : ").append(emit(result.getScore())).append(",");
                     sb.append("\"scoreError\" : ").append(emit(runResult.getPrimaryResult().getStatistics().getMeanErrorAt(0.999))).append(",");
                     sb.append("\"scoreConfidence\" : ").append(emit(result.getStatistics().getConfidenceIntervalAt(0.999))).append(",");
+                    sb.append(emitPercentiles(result.getStatistics()));
                     sb.append("\"scoreUnit\" : \"").append(result.getScoreUnit()).append("\",");
                     sb.append("\"rawData\" :");
 
@@ -134,6 +137,24 @@
         }
     }
 
+    private String emitPercentiles(Statistics stats) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("\"scorePercentiles\" : {");
+        boolean firstPercentile = true;
+        for (double p : new double[] {0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 0.99999, 0.999999, 1.0}) {
+            if (firstPercentile) {
+                firstPercentile = false;
+            } else {
+                sb.append(",");
+            }
+
+            double v = stats.getPercentile(p * 100);
+            sb.append(String.format("\"%.4f\" : %.3f", p*100, v));
+        }
+        sb.append("},");
+        return sb.toString();
+    }
+
     private String emit(double[] ds) {
         StringBuilder sb = new StringBuilder();
 
--- a/jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.json	Mon Feb 17 23:47:05 2014 +0400
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.json	Tue Feb 18 00:26:22 2014 +0400
@@ -15,6 +15,18 @@
                 250.7151898828282,
                 806.9990958314576
             ],
+            "scorePercentiles" : {
+                "0.0000" : 87.000,
+                "50.0000" : 567.500,
+                "90.0000" : 884.000,
+                "95.0000" : 942.000,
+                "99.0000" : 942.000,
+                "99.9000" : 942.000,
+                "99.9900" : 942.000,
+                "99.9990" : 942.000,
+                "99.9999" : 942.000,
+                "100.0000" : 942.000
+            },
             "scoreUnit" : "ops/ms",
             "rawData" : [
                 [
@@ -55,6 +67,18 @@
                     229.48679759181687,
                     869.9417738367545
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 54.000,
+                    "50.0000" : 527.000,
+                    "90.0000" : 935.000,
+                    "95.0000" : 952.000,
+                    "99.0000" : 952.000,
+                    "99.9000" : 952.000,
+                    "99.9900" : 952.000,
+                    "99.9990" : 952.000,
+                    "99.9999" : 952.000,
+                    "100.0000" : 952.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -94,6 +118,18 @@
                     296.2904152116224,
                     934.7095847883776
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 56.000,
+                    "50.0000" : 724.500,
+                    "90.0000" : 967.500,
+                    "95.0000" : 992.000,
+                    "99.0000" : 992.000,
+                    "99.9000" : 992.000,
+                    "99.9900" : 992.000,
+                    "99.9990" : 992.000,
+                    "99.9999" : 992.000,
+                    "100.0000" : 992.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -145,6 +181,18 @@
                 "NaN",
                 "NaN"
             ],
+            "scorePercentiles" : {
+                "0.0000" : 439.000,
+                "50.0000" : 439.000,
+                "90.0000" : 439.000,
+                "95.0000" : 439.000,
+                "99.0000" : 439.000,
+                "99.9000" : 439.000,
+                "99.9900" : 439.000,
+                "99.9990" : 439.000,
+                "99.9999" : 439.000,
+                "100.0000" : 439.000
+            },
             "scoreUnit" : "ops/ms",
             "rawData" : [
                 [
@@ -160,6 +208,18 @@
                     "NaN",
                     "NaN"
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 953.000,
+                    "50.0000" : 953.000,
+                    "90.0000" : 953.000,
+                    "95.0000" : 953.000,
+                    "99.0000" : 953.000,
+                    "99.9000" : 953.000,
+                    "99.9900" : 953.000,
+                    "99.9990" : 953.000,
+                    "99.9999" : 953.000,
+                    "100.0000" : 953.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -174,6 +234,18 @@
                     "NaN",
                     "NaN"
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 367.000,
+                    "50.0000" : 367.000,
+                    "90.0000" : 367.000,
+                    "95.0000" : 367.000,
+                    "99.0000" : 367.000,
+                    "99.9000" : 367.000,
+                    "99.9900" : 367.000,
+                    "99.9990" : 367.000,
+                    "99.9999" : 367.000,
+                    "100.0000" : 367.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -200,6 +272,18 @@
                 -8.336699425307074,
                 1098.336699425307
             ],
+            "scorePercentiles" : {
+                "0.0000" : 100.000,
+                "50.0000" : 497.000,
+                "90.0000" : 986.000,
+                "95.0000" : 986.000,
+                "99.0000" : 986.000,
+                "99.9000" : 986.000,
+                "99.9900" : 986.000,
+                "99.9990" : 986.000,
+                "99.9999" : 986.000,
+                "100.0000" : 986.000
+            },
             "scoreUnit" : "ops/ms",
             "rawData" : [
                 [
@@ -225,6 +309,18 @@
                     -30.738060009237756,
                     899.6269488981267
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 88.000,
+                    "50.0000" : 499.000,
+                    "90.0000" : 823.000,
+                    "95.0000" : 823.000,
+                    "99.0000" : 823.000,
+                    "99.9000" : 823.000,
+                    "99.9900" : 823.000,
+                    "99.9990" : 823.000,
+                    "99.9999" : 823.000,
+                    "100.0000" : 823.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -249,6 +345,18 @@
                     -31.939707850174727,
                     972.6063745168414
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 151.000,
+                    "50.0000" : 339.000,
+                    "90.0000" : 974.000,
+                    "95.0000" : 974.000,
+                    "99.0000" : 974.000,
+                    "99.9000" : 974.000,
+                    "99.9900" : 974.000,
+                    "99.9990" : 974.000,
+                    "99.9999" : 974.000,
+                    "100.0000" : 974.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -285,6 +393,18 @@
                 54.7574615121369,
                 780.3853956307203
             ],
+            "scorePercentiles" : {
+                "0.0000" : 21.000,
+                "50.0000" : 396.500,
+                "90.0000" : 890.000,
+                "95.0000" : 979.000,
+                "99.0000" : 979.000,
+                "99.9000" : 979.000,
+                "99.9900" : 979.000,
+                "99.9990" : 979.000,
+                "99.9999" : 979.000,
+                "100.0000" : 979.000
+            },
             "scoreUnit" : "ops/ms",
             "rawData" : [
                 [
@@ -319,6 +439,18 @@
                     384.2320746802016,
                     960.1964967483698
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 232.000,
+                    "50.0000" : 686.000,
+                    "90.0000" : 975.000,
+                    "95.0000" : 983.000,
+                    "99.0000" : 983.000,
+                    "99.9000" : 983.000,
+                    "99.9900" : 983.000,
+                    "99.9990" : 983.000,
+                    "99.9999" : 983.000,
+                    "100.0000" : 983.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -352,6 +484,18 @@
                     270.3428956913269,
                     849.9428185943873
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 114.000,
+                    "50.0000" : 559.500,
+                    "90.0000" : 866.500,
+                    "95.0000" : 870.000,
+                    "99.0000" : 870.000,
+                    "99.9000" : 870.000,
+                    "99.9900" : 870.000,
+                    "99.9990" : 870.000,
+                    "99.9999" : 870.000,
+                    "100.0000" : 870.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -397,6 +541,18 @@
                 "NaN",
                 "NaN"
             ],
+            "scorePercentiles" : {
+                "0.0000" : 956.000,
+                "50.0000" : 956.000,
+                "90.0000" : 956.000,
+                "95.0000" : 956.000,
+                "99.0000" : 956.000,
+                "99.9000" : 956.000,
+                "99.9900" : 956.000,
+                "99.9990" : 956.000,
+                "99.9999" : 956.000,
+                "100.0000" : 956.000
+            },
             "scoreUnit" : "ops/ms",
             "rawData" : [
                 [
@@ -412,6 +568,18 @@
                     "NaN",
                     "NaN"
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 688.000,
+                    "50.0000" : 688.000,
+                    "90.0000" : 688.000,
+                    "95.0000" : 688.000,
+                    "99.0000" : 688.000,
+                    "99.9000" : 688.000,
+                    "99.9900" : 688.000,
+                    "99.9990" : 688.000,
+                    "99.9999" : 688.000,
+                    "100.0000" : 688.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [
@@ -426,6 +594,18 @@
                     "NaN",
                     "NaN"
                 ],
+                "scorePercentiles" : {
+                    "0.0000" : 237.000,
+                    "50.0000" : 237.000,
+                    "90.0000" : 237.000,
+                    "95.0000" : 237.000,
+                    "99.0000" : 237.000,
+                    "99.9000" : 237.000,
+                    "99.9900" : 237.000,
+                    "99.9990" : 237.000,
+                    "99.9999" : 237.000,
+                    "100.0000" : 237.000
+                },
                 "scoreUnit" : "ops/ms",
                 "rawData" :[
                     [