-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
jmh.gradle
79 lines (65 loc) · 1.94 KB
/
jmh.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Java microbenchmark harness: https://github.com/melix/jmh-gradle-plugin
*/
import org.gradle.plugins.ide.eclipse.model.Library
apply plugin: 'io.morethan.jmhreport'
apply plugin: 'me.champeau.jmh'
idea.module {
scopes.PROVIDED.plus += [ configurations.jmh ]
}
eclipse.classpath.file.whenMerged {
entries.find { it.path == 'src/jmh/java' }.entryAttributes['test'] = 'true'
entries.removeIf { (it instanceof Library) && (it.moduleVersion?.name == 'slf4j-nop') }
}
configurations {
jmh {
exclude module: 'slf4j-test'
}
}
dependencies {
afterEvaluate {
jmh configurations.testImplementation.allDependencies
}
}
tasks.named('jmh').configure {
group = 'Benchmarks'
description = 'Executes a Java microbenchmark'
}
jmh {
jmhVersion = versions.jmh
if (project.hasProperty('includePattern')) {
includes = [ project.includePattern ]
} else {
tasks.jmh.doFirst { throw new GradleException('jmh: includePattern expected') }
}
// Benchmark parameters: Separated by '&' for parameter types, and ',' for multiple values
if (project.hasProperty('benchmarkParameters')) {
benchmarkParameters = project.benchmarkParameters.split('&').inject([:]) { map, token ->
token.split('=').with { map[it[0]] = (it[1].split(',') as List) }
map
}
}
// Benchmark mode: Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all
benchmarkMode = ['thrpt']
// Available time units are: [m, s, ms, us, ns]
timeUnit = 's'
resultFormat = 'json'
resultsFile = file("${buildDir}/reports/jmh/results.json")
jvmArgs = [ '-Xmx2G' ]
warmupIterations = 3
failOnError = true
iterations = 3
forceGC = true
fork = 1
}
jmhReport {
jmhResultPath = jmh.resultsFile.get()
jmhReportOutput = file("${buildDir}/reports/jmh")
}
tasks.named('jmh').configure {
dependsOn(bundle)
finalizedBy(tasks.jmhReport)
}
tasks.named('compileJmhJava').configure {
options.errorprone.disable('NullAway')
}