artyushov / idea-jmh-plugin

Plugin for Itellij IDEA to make benchmarking with JMH easier.
MIT License
445 stars 43 forks source link

Question: can we change the location of generated benchmark classes? #49

Open cbotiza opened 11 months ago

cbotiza commented 11 months ago

Having looked at the plugin code I was not able to find a way to change the location of generated benchmark classes. With a typical gradle setup, whereby JMH sources are under src/jmh, running the benchmarks with the help of this plugin causes the JmhBytecodeGenerator to write generated java code under src/jmh/generated_tests. Would it be possible to make this configurable? Having looked (just a bit) at the JMH code as well, it appears JmhBytecodeGenerator accepts that path as command line argument. But I couldn't find a way to pass a different value. I think generated_tests is some default from IDEA - not sure how we could change it. Any ideas? Am I missing something?

Ideally:

stokito commented 11 months ago

Sorry, I probably can't help you. Usually the JMH benchmarks are created as a separate Maven project that can import modules from the project that you wish to test. The JMH uses a Maven plugin to generate code wrapped in JMH sampling code. So Gradle support may not work at all.

Just checked REAMDE of the JMH itself:

The recommended way to run a JMH benchmark is to use Maven to setup a standalone project that depends on the jar files of your application. This approach is preferred to ensure that the benchmarks are correctly initialized and produce reliable results. It is possible to run benchmarks from within an existing project, and even from within an IDE, however setup is more complex and the results are less reliable.

In all cases, the key to using JMH is enabling the annotation- or bytecode-processors to generate the synthetic benchmark code. Maven archetypes are the primary mechanism used to bootstrap the project that has the proper build configuration. We strongly recommend new users make use of the archetype to setup the correct environment.

But I may check later (probably in a year) the usage scenario that you described.

cbotiza commented 11 months ago

Thank you for your reply. If I have time I will look into it as well and hopefully even contribute

stokito commented 11 months ago

Idea plugin development is very time expensive so keep away from it :) This is not critical feature at all. So unless others will request it we probabbly won't do anything in the direction. Let's keep the issue open and see for votes