Skip to content

Commit

Permalink
Adding JMH benchmarks (#72)
Browse files Browse the repository at this point in the history
* Adding JMH benchmarks

Fixes #9
  • Loading branch information
Nathan Mittler authored Feb 1, 2017
1 parent e6bccba commit f998b64
Show file tree
Hide file tree
Showing 10 changed files with 681 additions and 20 deletions.
23 changes: 22 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ subprojects {
version = "1.0.0-SNAPSHOT"

ext {
os = org.gradle.internal.os.OperatingSystem.current();
if (os.isLinux()) {
osName = "linux"
} else if (os.isMacOsX()) {
osName = "osx"
} else if (os.isWindows()) {
osName = "windows"
} else {
throw new GradleException("Unsupported os: " + os.name)
}

boringsslHome = "$System.env.BORINGSSL_HOME"
boringsslIncludeDir = "$boringsslHome/include"
boringssl32BuildDir = "$boringsslHome/build32"
Expand All @@ -53,15 +64,22 @@ subprojects {
assert file("$jdkHome").exists()
assert file("$jdkIncludeDir").exists()

jmhVersion = '1.17.4'
libraries = [
roboelectric: 'org.robolectric:android-all:5.0.0_r2-robolectric-1',

// Test dependencies.
guava : 'com.google.guava:guava:19.0',
junit : 'junit:junit:4.11',
mockito: 'org.mockito:mockito-core:1.9.5',
truth : 'com.google.truth:truth:0.28',
bouncycastle_provider: 'org.bouncycastle:bcprov-jdk15on:1.55',
bouncycastle_apis: 'org.bouncycastle:bcpkix-jdk15on:1.55'
bouncycastle_apis: 'org.bouncycastle:bcpkix-jdk15on:1.55',

// Benchmark dependencies
jmh_generator_annprocess : "org.openjdk.jmh:jmh-generator-annprocess:$jmhVersion",
netty: 'io.netty:netty-codec-http2:4.1.8.Final',
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26',
]
}

Expand All @@ -72,6 +90,9 @@ subprojects {
}

if (!androidProject) {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

[compileJava, compileTestJava].each() {
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options", '-Xmaxwarns', '9999999']
it.options.encoding = "UTF-8"
Expand Down
47 changes: 47 additions & 0 deletions openjdk-benchmarks/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id 'me.champeau.gradle.jmh' version '0.3.1'
}

apply plugin: 'idea'

description = 'Conscrypt: OpenJDK Benchmarks'

ext {
// The configuration of conscrypt-openjdk to use. This configuration will contain the native artifact for
// the current platform.
openJdkConfiguration = normalizeClassifier(classifierFor(osName, 'x86_64'))
}

jmh {
jmhVersion = "$jmhVersion"
warmupIterations = 10
iterations = 10
fork = 1
jvmArgs = '-server -Xms2g -Xmx2g'
duplicateClassesStrategy = 'warn'
}

dependencies {
compile project(path: ':conscrypt-openjdk', configuration: "$openJdkConfiguration"), libraries.guava
jmh libraries.junit,
libraries.netty,
libraries.netty_tcnative,
// JMH plugin doesn't seem to include this dependency by default. This version of the JMH
// plugin seems to require the use of v1.12 for all other JMH dependencies, so not overriding
// them here.
libraries.jmh_generator_annprocess
}

// Running benchmarks in IntelliJ seems broken without this.
// See https://github.com/melix/jmh-gradle-plugin/issues/39
idea.module {
scopes.PROVIDED.plus += [ configurations.jmh ]
}

static classifierFor(osName, archName) {
return "${osName}-${archName}"
}

static normalizeClassifier(classifier) {
return classifier.replaceAll("-", "_")
}
Loading

0 comments on commit f998b64

Please sign in to comment.