1plugins { 2 id 'me.champeau.gradle.jmh' version '0.3.1' 3} 4 5apply plugin: 'idea' 6 7description = 'Conscrypt: JMH on OpenJDK Benchmarks' 8 9evaluationDependsOn(':conscrypt-openjdk') 10 11ext { 12 preferredNativeConfiguration = project(':conscrypt-openjdk').preferredNativeConfiguration 13 preferredNativeFileDir = project(':conscrypt-openjdk').preferredNativeFileDir 14 15 genDir = "${buildDir}/jmh-generated-classes" 16 jmhInclude = System.getProperty('jmh.include') 17 jmhWarmupIterations = System.getProperty('jmh.wi', '10') 18 jmhIterations = System.getProperty('jmh.i', '10') 19 jmhFork = System.getProperty('jmh.f', '1') 20 jmhJvm = System.getProperty('jmh.jvm') 21 jmhJvmArgs = System.getProperty('jmh.jvmArgs', '-server -Xms2g -Xmx2g') 22} 23 24// We're not distributing this, so it's safe to use newer language features. 25sourceCompatibility = JavaVersion.VERSION_1_8 26targetCompatibility = JavaVersion.VERSION_1_8 27 28jmh { 29 jmhVersion = "$jmhVersion" 30 if (jmhInclude != null) { 31 setInclude(jmhInclude.toString()) 32 } 33 warmupIterations = "$jmhWarmupIterations".toInteger() 34 iterations = "$jmhIterations".toInteger(); 35 fork = "$jmhFork".toInteger() 36 jvmArgs = jmhJvmArgs.toString() 37 if (jmhJvm != null) { 38 jvm = jmhJvm 39 } 40 duplicateClassesStrategy = 'warn' 41} 42 43configurations { 44 // The JMH plugin by defaults depends on all of the generators for an old version of JMH. 45 // Need to remove all the generators that we're not explicitly overriding to eliminate the 46 // dependency on the old version of JMH. 47 jmh.exclude module:'jmh-generator-asm' 48 49 jmhGeneratorAnnprocess 50} 51 52sourceSets { 53 sourceSets { 54 main { 55 resources { 56 // This shouldn't be needed but seems to help IntelliJ locate 57 // META_INF/BenchmarkList. 58 srcDirs += genDir 59 60 // This shouldn't be needed but seems to help IntelliJ locate the native artifact. 61 srcDirs += preferredNativeFileDir 62 } 63 } 64 } 65} 66 67dependencies { 68 compile project(':conscrypt-openjdk'), 69 project(':conscrypt-benchmark-base'), 70 // Add the preferred native openjdk configuration for this platform. 71 project(path: ':conscrypt-openjdk', configuration: "$preferredNativeConfiguration"), 72 libraries.junit, 73 libraries.netty_handler, 74 libraries.netty_tcnative 75 76 jmhGeneratorAnnprocess libraries.jmh_generator_annprocess 77 78 // Override the default JMH dependencies with the new versions. 79 jmh libraries.jmh_core, 80 libraries.jmh_generator_reflection, 81 libraries.jmh_generator_bytecode 82} 83 84// Running benchmarks in IntelliJ seems broken without this. 85// See https://github.com/melix/jmh-gradle-plugin/issues/39 86idea.module { 87 scopes.PROVIDED.plus += [ configurations.compile, configurations.jmh ] 88} 89 90// Don't include this artifact in the distribution. 91tasks.install.enabled = false 92tasks.uploadArchives.enabled = false; 93