Running benchmarks with groovy classes

Aaron Tull atull at netflix.com
Tue Feb 18 14:07:35 PST 2014


Hi Aleksey,
Thanks for the fast response. As it turns out there is a gradle issue where
the java compilation is done before the groovy compilation step. We
declared a new sourceSet for benchmarking separate from the main or test
sourceSet and the way we configured it was prone to this problem. Here is
the gradle file and comments for the work around.


defaultTasks 'build'

apply plugin: 'java'
apply plugin: 'groovy'

repositories { mavenCentral() }

sourceSets {
    bench {
        groovy {
        //    groovy compiler now compiles both java and groovy
        //    srcDir 'src/bench/groovy'
            srcDirs = ['src/bench/groovy', 'src/bench/java']
        }
        java {
        //    removed all java sources to be compiled by groovy
        //    srcDir 'src/bench/java'
            srcDirs = []
            compileClasspath += main.output
            runtimeClasspath += main.output
        }
    }
}

configurations {
    benchCompile { extendsFrom compile }
    benchRuntime { extendsFrom runtime }
}

dependencies {
    benchCompile localGroovy()
    benchCompile 'org.openjdk.jmh:jmh-core:0.3.2'
}

task time(type:JavaExec) {
    classpath = sourceSets.bench.runtimeClasspath
    group 'Application'
    description 'Execute the benchmark timing of this application'
    main 'RunBenchmarks'
}




On Tue, Feb 18, 2014 at 1:23 PM, Aleksey Shipilev <
aleksey.shipilev at oracle.com> wrote:

> Hi Aaron,
>
> On 02/19/2014 01:17 AM, Aaron Tull wrote:
> > (skipped)
> > When I run this as a benchmark I get compilation errors "error: cannot
> find
> > symbol" MyBench. I have this project setup properly in gradle to use the
> > groovy compiler. Has anyone seen problems like this before or have a work
> > around?
>
> As far as I can tell from your description, it should work. Do you mind
> sharing the sample benchmark code for us to debug?
>
> Thanks,
> -Aleksey.
>
>
>
>


More information about the jmh-dev mailing list