From 33d46d33b23aaec9019c92c52dc4cea23a78f272 Mon Sep 17 00:00:00 2001 From: matyasberry Date: Thu, 16 Mar 2023 14:26:27 +0100 Subject: [PATCH] support for JMH parameters (as separate charts) --- src/extract.ts | 4 +- test/data/extract/jmh_output_2.json | 57 +++++++++++++++++++++++++++++ test/extract.spec.ts | 12 ++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 test/data/extract/jmh_output_2.json diff --git a/src/extract.ts b/src/extract.ts index 1b6b2ff25..c21ec55fe 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -188,6 +188,7 @@ export interface JmhBenchmarkJson { measurementIterations: number; measurementTime: string; measurementBatchSize: number; + params: object; primaryMetric: { score: number; scoreError: number; @@ -610,8 +611,9 @@ function extractJmhResult(output: string): BenchmarkResult[] { const name = b.benchmark; const value = b.primaryMetric.score; const unit = b.primaryMetric.scoreUnit; + const params = b.params ? ' ( ' + JSON.stringify(b.params) + ' )' : ''; const extra = `iterations: ${b.measurementIterations}\nforks: ${b.forks}\nthreads: ${b.threads}`; - return { name, value, unit, extra }; + return { name: name + params, value, unit, extra }; }); } diff --git a/test/data/extract/jmh_output_2.json b/test/data/extract/jmh_output_2.json new file mode 100644 index 000000000..882e30a9a --- /dev/null +++ b/test/data/extract/jmh_output_2.json @@ -0,0 +1,57 @@ +[ + { + "jmhVersion" : "1.29", + "benchmark" : "org.openjdk.jmh.samples.JMHSample_01_HelloWorld.wellHelloThere", + "mode" : "thrpt", + "threads" : 1, + "forks" : 1, + "jvm" : "/home/mmior/.jabba/jdk/1.8.202/jre/bin/java", + "jvmArgs" : [ + ], + "jdkVersion" : "1.8.0_202", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "25.202-b08", + "warmupIterations" : 1, + "warmupTime" : "10 s", + "warmupBatchSize" : 1, + "measurementIterations" : 3, + "measurementTime" : "10 s", + "measurementBatchSize" : 1, + "params" : { + "paramA" : "17", + "paramB" : "33" + }, + "primaryMetric" : { + "score" : 3.3762388731228185E9, + "scoreError" : 1.4287985743935993E7, + "scoreConfidence" : [ + 3.3619508873788824E9, + 3.3905268588667545E9 + ], + "scorePercentiles" : { + "0.0" : 3.375353964729294E9, + "50.0" : 3.37651988895058E9, + "90.0" : 3.376842765688582E9, + "95.0" : 3.376842765688582E9, + "99.0" : 3.376842765688582E9, + "99.9" : 3.376842765688582E9, + "99.99" : 3.376842765688582E9, + "99.999" : 3.376842765688582E9, + "99.9999" : 3.376842765688582E9, + "100.0" : 3.376842765688582E9 + }, + "scoreUnit" : "ops/s", + "rawData" : [ + [ + 3.376842765688582E9, + 3.37651988895058E9, + 3.375353964729294E9 + ] + ] + }, + "secondaryMetrics" : { + } + } +] + + diff --git a/test/extract.spec.ts b/test/extract.spec.ts index b61bf681d..a30faacbf 100644 --- a/test/extract.spec.ts +++ b/test/extract.spec.ts @@ -373,6 +373,18 @@ describe('extractResult()', function () { }, ], }, + { + tool: 'jmh', + file: 'jmh_output_2.json', + expected: [ + { + extra: 'iterations: 3\nforks: 1\nthreads: 1', + name: 'org.openjdk.jmh.samples.JMHSample_01_HelloWorld.wellHelloThere ( {"paramA":"17","paramB":"33"} )', + unit: 'ops/s', + value: 3.3762388731228185e9, + }, + ], + }, { tool: 'benchmarkdotnet', file: 'benchmarkdotnet.json',