How do I prevent JMH from initializing non-JMH-related classes on every benchmark?

Timmae219 timerdar at googlemail.com
Thu Dec 2 12:42:50 UTC 2021


Hello JMH devs, 

I don’t know if this mailing list is meant to handle questions like these, but I think the chances to get help is bigger here than anywhere else (e.g. Stack Overflow). If not, please tell me that.

I am currently working on a very special project which uses also JMH. The program should monitor the energy consumption of the System with the Intel Power Gadget during a JMH Benchmark. During analyzing some other concurrency problems I found out that my PowerGadgetProfiler class, which has only static members, has been initialized every time a new benchmark has begun. But I want it to be initialized just once in the whole program (at the beginning). 

I tried to find an annotation in JMH which does that and I also tried to investigate the JMH-core code to solve my problem but I wasn’t able to. I hope you can help me.

Best regards,
Tim Erdar



More information about the jmh-dev mailing list