Control the order of methods using JMH

I am using the JMH test in my project. I have method 1 and method 2 annotated with @Benchmark. I want the order to be: method1, method2, mehod1, method2 ... and so on ... This means: I wand that method 2 will immediately follow method 1. Is there a way to do this?

Thank!

+4
source share
1 answer

The order in which JMH executes the methods @Benchmarkusually does not matter: the runs are isolated from each other, so the results are independent. But if you still need a specific order, then @Benchmark-s are executed in lexicographic order, therefore, rename your methods in that order.

+2
source

All Articles