JMH does not recognise @State annotation on Groovy classes
Aleksey Shipilev
aleksey.shipilev at oracle.com
Mon Oct 19 13:47:33 UTC 2015
Hi,
Can you make a complete reproducible example?
I generated the Groovy benchmark project from the archetype, adjusted
the dependency to Groovy 2.2.2, copied your code in, adjusted imports,
and it built fine.
Thanks,
-Aleksey
On 10/19/2015 09:31 AM, Gabor Nagy wrote:
> E.g:
>
> JmhModelsX.groovy:
>
> @State(Scope.Thread)
> class JmhModelsX {
>
> private double total
>
> @Benchmark
> public void test() {
> total = total + 23.0;
> }
>
> public static void main(String[] args) throws IOException, RunnerException {
> Options opt = new OptionsBuilder()
> .include(".*" + JmhModelsX.class.getSimpleName() + ".*")
> .forks(1)
> // for fast debug
> .warmupIterations(3).measurementIterations(3)
> .build();
> new Runner(opt).run();
> }
> }
>
>
> [ERROR]
> /home/xxx/git/cpox-opt/cpox-opt-pom/rater/src/test/java/benchmarks/JmhModelsX.groovy:[14,-1]
> [ERROR] 3. ERROR in
> /home/xxx/git/cpox-opt/cpox-opt-pom/rater/src/test/java/benchmarks/JmhModelsX.groovy
> (at line 14)
> [ERROR] private double total
> [ERROR] ^^^^^
> [ERROR] Field "total" is declared within the class not having @State
> annotation. This can result in unspecified behavior, and prohibited.
More information about the jmh-dev
mailing list