May need to use toJSONString on @Param values
Will Reichert
willr3 at gmail.com
Mon Jan 7 15:01:44 UTC 2019
The json output format breaks when a @Param value contains a [ or {.
The issue exists in 1.21 and 1.22-SNAPSHOT (built from master)
I was able to fix it by changing line 195
in ./jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java
to the following
sb.append(toJsonString(params.getParam(k)));
recreate benchmark (starting with the maven example on
https://openjdk.java.net/projects/code-tools/jmh/):
package org.sample;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.*;
@State(Scope.Benchmark)
public class MyBenchmark {
@Param({"[broken]","{broken}"})
public String value;
@Benchmark
public void testMethod() {
// This is a demo/sample template for building your JMH benchmarks.
Edit as needed.
// Put your benchmark code here.
}
}
command: java -jar target/benchmarks.jar -f 1 -i 1 -wi 0 -r 10 -rf json
What is the best way to propose this change to JSONResultFormat?
--Will
More information about the jmh-dev
mailing list