Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cbotiza opened this issue Dec 11, 2023 · 3 comments
Open

Comments

@cbotiza
Copy link

cbotiza commented Dec 11, 2023

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:

  • the gradle jmh plugin would allow us to customize this location
  • Upon import, IntelliJ would adapt and pass the option to the JMH runner.
    Thank you very much!
@stokito
Copy link
Collaborator

stokito commented Dec 11, 2023

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
Copy link
Author

cbotiza commented Dec 11, 2023

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

@stokito
Copy link
Collaborator

stokito commented Dec 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants