From 8ee5d375347e86528d4b5db59dcb8cb86ee991b6 Mon Sep 17 00:00:00 2001 From: joehni Date: Mon, 28 Oct 2024 23:47:10 +0100 Subject: [PATCH] Adjust Parser Benchmark to measure deeply nested structure. --- .../xstream/benchmark/jmh/ParserBenchmark.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xstream-jmh/src/java/com/thoughtworks/xstream/benchmark/jmh/ParserBenchmark.java b/xstream-jmh/src/java/com/thoughtworks/xstream/benchmark/jmh/ParserBenchmark.java index eb462d23e..a8b0c2f71 100644 --- a/xstream-jmh/src/java/com/thoughtworks/xstream/benchmark/jmh/ParserBenchmark.java +++ b/xstream-jmh/src/java/com/thoughtworks/xstream/benchmark/jmh/ParserBenchmark.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2017, 2021 XStream Committers. + * Copyright (C) 2015, 2017, 2021, 2024 XStream Committers. * All rights reserved. * * The software in this package is published under the terms of the BSD @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import org.codehaus.jettison.json.JSONObject; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -69,6 +70,10 @@ @Threads(1) @Warmup(iterations = 5) public class ParserBenchmark { + { + // Increase max recursion depth for Jettison + JSONObject.setGlobalRecursionDepthLimit(2000); + } /** * Driver factory. Enum values used as parameter for the parser benchmark methods. @@ -229,7 +234,7 @@ public void checkData(final Object o) { } }, /** - * Nested list in list structure, 500 elements deep. + * Nested list in list structure, 1000 elements deep. * * @author Jörg Schaible * @since 1.4.9 @@ -331,6 +336,7 @@ public void init() { xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypes(List.class, String.class); xstream.setMode(XStream.NO_REFERENCES); + xstream.setCollectionUpdateLimit(0); driver = driverFactory.getDriver(); }