diff --git a/bosk-jackson/src/test/java/works/bosk/jackson/JacksonRoundTripBenchmark.java b/bosk-jackson/src/test/java/works/bosk/jackson/JacksonRoundTripBenchmark.java index b9ab2073..b53d35f3 100644 --- a/bosk-jackson/src/test/java/works/bosk/jackson/JacksonRoundTripBenchmark.java +++ b/bosk-jackson/src/test/java/works/bosk/jackson/JacksonRoundTripBenchmark.java @@ -66,27 +66,31 @@ public void setup() throws InvalidTypeException, JsonProcessingException { this.jacksonPlugin = new JacksonPlugin(); this.mapper = new ObjectMapper().registerModule(jacksonPlugin.moduleFor(bosk)); rootRef = bosk.rootReference(); - TestRoot localRoot = root1 = rootRef.value(); + try (var _ = bosk.readContext()) { + root1 = rootRef.value(); + } // Make a separate identical state object, cloning via JSON String json = mapper.writerFor(rootRef.targetClass()).writeValueAsString(root1); root2 = mapper.readerFor(rootRef.targetClass()).readValue(json); } + @Setup(Level.Invocation) + public void resetBoskState() { + bosk.driver().submitReplacement(rootRef, root1); + } } @Benchmark @BenchmarkMode(AverageTime) public void replacementOverhead(BenchmarkState state) { state.downstreamDriver.submitReplacement(state.rootRef, state.root2); - state.downstreamDriver.submitReplacement(state.rootRef, state.root1); } @Benchmark @BenchmarkMode(AverageTime) public void replacement(BenchmarkState state) { state.driver.submitReplacement(state.rootRef, state.root2); - state.driver.submitReplacement(state.rootRef, state.root1); } }