Skip to content

Commit

Permalink
Fix JacksonRoundTripBenchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
prdoyle committed Nov 20, 2024
1 parent bbd4b74 commit 616921f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 616921f

Please sign in to comment.