-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
48 lines (42 loc) · 1.28 KB
/
build.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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.codehaus.groovy', name: 'groovy-json', version: '3.0.10'
}
}
plugins {
id "java"
id "me.champeau.jmh" version "0.6.6"
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
jmh {
resultFormat = 'JSON'
jvmArgs = ['-XX:-TieredCompilation']
}
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
task convertJmhResultForGithubActions {
doLast {
def jmhResults = project.file("${project.buildDir}/results/jmh/results.json")
if (!jmhResults.exists()) {
println 'Results does not exist'
return
}
def ghActionData = new JsonSlurper().parse(jmhResults).collect { benchmark ->
[
name : benchmark.benchmark,
value: benchmark.primaryMetric.score,
unit : benchmark.primaryMetric.scoreUnit,
extra: "iterations: ${benchmark.measurementIterations}\nforks: ${benchmark.forks}\nthreads: ${benchmark.threads}\nmode: ${benchmark.mode}"
]
}
project.file("${project.buildDir}/results/jmh/results-gh-benchmark.json").write(JsonOutput.toJson(ghActionData))
}
mustRunAfter "jmh"
}