Unfortunately, JMH does not provide the ability to exchange data between standards.
On the one hand, this violates the isolation of benchmarks, when one control test can silently change the input data for another test, making the comparison incorrect. This is why you need the @Setup object for each test.
But more importantly, any trick that you create for sharing data between standards (for example, the static field, available from both) will break in default forked mode when JMH runs each test in its own virtual machine. It is noteworthy that what you propose using static final Data TestSet.PARSE_ME will indeed be executed for each @Benchmark , since each new instance of the virtual machine must in some way initialize TestSet ;). Of course, you can turn off forking, but this creates more problems than it solves.
Thus, it might be better to think about investing time in making installation costs more bearable, so it is not excruciatingly painful. For example, deserialize data from disk, rather than calculate it. Or just come up with a faster way to calculate.
source share