On 2020-08-27 16:11, Alan Bateman wrote:
For the micro, I'm curious if iterations is needed.
I'd say the canonical JMH way of doing these might be something as simple as this: @Benchmark public URI encodeURI() throws URISyntaxException { return new URI("http", "\u00A0", "\u00A0"); } @Benchmark public String decodeURI() throws URISyntaxException { return decoderUri.getPath(); } Sometimes for very simple micros like this this means the workload gets inlined so aggressively that you no longer measure what is likely to happen in the real world, and it's then not uncommon to force the benchmark method to not be inlined up into the JMH framework by annotating them with this: @CompilerControl(CompilerControl.Mode.DONT_INLINE) See for example org/openjdk/bench/java/util/ImmutableColls.java If you run with these suggestions you'll only one have encode/decode per iteration, so you might want to change output to nanoseconds, i.e.: @OutputTimeUnit(TimeUnit.NANOSECONDS) Thanks! /Claes