melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle
Apache License 2.0
666 stars 88 forks source link

Is it possible to extend the "jmh" task? #161

Closed Vetii closed 4 years ago

Vetii commented 4 years ago

Hi!

I would like to have pre-configured versions of the "jmh" task, and I have used the snippets described in this link.

I tried to write:

task jmhMyTask(type: me.champeau.gradle.JMHTask_Decorated) {
    fork = 2,
    resultFormat="CSV"
}

But if I do that, I get the following error:

Could not set unknown property 'fork' for task ':jmhTest' of type me.champeau.gradle.JMHTask_Decorated.

(I used "JMHTask_Decorated", because that is what I get when printing tasks.jmh.getClass().

Is there a way to define pre-configured versions of the "jmh" task?

Gradle version: 5.2.1. Plugin version: 0.4.8.

melix commented 4 years ago

Don't use _Decorated, this is something generated by Gradle for any task. Just use:

task jmhMyTask(type: me.champeau.gradle.JMHTask

Vetii commented 4 years ago

Hi,

I tried to use jmhTask, but the problem persists, if I write:

task jmhTest(type: me.champeau.gradle.JMHTask) {
    fork=2
    timeOnIteration="250ms"
    resultFormat="CSV"
}

Then the build fails with the following error

Could not set unknown property 'fork' for task ':jmhTest' of type me.champeau.gradle.JMHTask.

Is there some other syntax that should be used for setting the properties?