Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control the order of methods using JMH

Tags:

java

jmh

I'm using JMH benchmark 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... Which means: I wand that method 2 will immediately follow method 1. Is there a way to do so?

Thank you!

like image 528
TaliG Avatar asked Mar 28 '16 11:03

TaliG


1 Answers

The order in which JMH executes @Benchmark methods is usually irrelevant: the runs are isolated from each other, and so results are independent. But in case you still want the particular order, then @Benchmark-s are executed in the lexicographical order, hence, rename your methods in that order.

like image 74
Aleksey Shipilev Avatar answered Oct 17 '22 15:10

Aleksey Shipilev