plugins { id 'me.champeau.gradle.jmh' version '0.4.7' } apply plugin: 'idea' description = 'Conscrypt: JMH on OpenJDK Benchmarks' evaluationDependsOn(':conscrypt-openjdk') ext { preferredSourceSet = project(':conscrypt-openjdk').preferredSourceSet preferredNativeFileDir = project(':conscrypt-openjdk').preferredNativeFileDir genDir = "${buildDir}/jmh-generated-classes" jmhInclude = System.getProperty('jmh.include') jmhParams = System.getProperty('jmh.parameters') jmhWarmupIterations = System.getProperty('jmh.wi', '10') jmhIterations = System.getProperty('jmh.i', '10') jmhFork = System.getProperty('jmh.f', '1') jmhJvm = System.getProperty('jmh.jvm') jmhJvmArgs = System.getProperty('jmh.jvmArgs', '-server -Xms2g -Xmx2g') } // We're not distributing this, so it's safe to use newer language features. sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 jmh { jmhVersion = "$jmhVersion" if (jmhInclude != null) { setInclude(jmhInclude.toString()) } if (jmhParams != null) { setBenchmarkParameters(parseParams(jmhParams)) } warmupIterations = "$jmhWarmupIterations".toInteger() iterations = "$jmhIterations".toInteger(); fork = "$jmhFork".toInteger() jvmArgs = jmhJvmArgs.toString() if (jmhJvm != null) { jvm = jmhJvm } duplicateClassesStrategy = 'warn' } configurations { // The JMH plugin by defaults depends on all of the generators for an old version of JMH. // Need to remove all the generators that we're not explicitly overriding to eliminate the // dependency on the old version of JMH. jmh.exclude module:'jmh-generator-asm' jmhGeneratorAnnprocess } sourceSets { sourceSets { main { resources { // This shouldn't be needed but seems to help IntelliJ locate // META_INF/BenchmarkList. srcDirs += genDir // This shouldn't be needed but seems to help IntelliJ locate the native artifact. srcDirs += preferredNativeFileDir } } } } dependencies { compile project(':conscrypt-openjdk'), project(':conscrypt-benchmark-base'), // Add the preferred native openjdk configuration for this platform. project(':conscrypt-openjdk').sourceSets["$preferredSourceSet"].output, libraries.junit, libraries.netty_handler, libraries.netty_tcnative jmhGeneratorAnnprocess libraries.jmh_generator_annprocess // Override the default JMH dependencies with the new versions. jmh libraries.jmh_core, libraries.jmh_generator_reflection, libraries.jmh_generator_bytecode } // Running benchmarks in IntelliJ seems broken without this. // See https://github.com/melix/jmh-gradle-plugin/issues/39 idea.module { scopes.PROVIDED.plus += [ configurations.compile, configurations.jmh ] } // Param strings are in the form "param:VAL1,VAL2;param2:VAL3,VAL4" def parseParams(s) { // It's really easy to type jmh.parameters=foo=bar instead of jmh.parameters=foo:bar, // so check for that. if (s.contains("=")) { throw new IllegalArgumentException("jmh.parameters value shouldn't include '='. (Did you mean ':'?)") } return s.split(";").collectEntries { entry -> def pair = entry.split(":") [ (pair.first().trim()) : pair.last().split(",").collect { it.trim() } ] } } // Don't include this artifact in the distribution. tasks.install.enabled = false tasks.uploadArchives.enabled = false;