forked from rsocket/rsocket-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
163 lines (134 loc) · 4.31 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
apply plugin: 'java'
apply plugin: 'idea'
configurations {
current
baseline {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
dependencies {
// Use the baseline to avoid using new APIs in the benchmarks
compileOnly "io.rsocket:rsocket-core:${perfBaselineVersion}"
compileOnly "io.rsocket:rsocket-transport-local:${perfBaselineVersion}"
implementation "org.openjdk.jmh:jmh-core:1.21"
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:1.21"
current project(':rsocket-core')
current project(':rsocket-transport-local')
baseline "io.rsocket:rsocket-core:${perfBaselineVersion}", {
changing = true
}
baseline "io.rsocket:rsocket-transport-local:${perfBaselineVersion}", {
changing = true
}
}
task jmhProfilers(type: JavaExec, description:'Lists the available profilers for the jmh task', group: 'Development') {
classpath = sourceSets.main.runtimeClasspath
main = 'org.openjdk.jmh.Main'
args '-lprof'
}
task jmh(type: JmhExecTask, description: 'Executing JMH benchmarks') {
classpath = sourceSets.main.runtimeClasspath + configurations.current
}
task jmhBaseline(type: JmhExecTask, description: 'Executing JMH baseline benchmarks') {
classpath = sourceSets.main.runtimeClasspath + configurations.baseline
}
class JmhExecTask extends JavaExec {
private String include;
private String fullInclude;
private String exclude;
private String format = "json";
private String profilers;
private String jmhJvmArgs;
private String verify;
public JmhExecTask() {
super();
}
public String getInclude() {
return include;
}
@Option(option = "include", description="configure bench inclusion using substring")
public void setInclude(String include) {
this.include = include;
}
public String getFullInclude() {
return fullInclude;
}
@Option(option = "fullInclude", description = "explicitly configure bench inclusion using full JMH style regexp")
public void setFullInclude(String fullInclude) {
this.fullInclude = fullInclude;
}
public String getExclude() {
return exclude;
}
@Option(option = "exclude", description = "explicitly configure bench exclusion using full JMH style regexp")
public void setExclude(String exclude) {
this.exclude = exclude;
}
public String getFormat() {
return format;
}
@Option(option = "format", description = "configure report format")
public void setFormat(String format) {
this.format = format;
}
public String getProfilers() {
return profilers;
}
@Option(option = "profilers", description = "configure jmh profiler(s) to use, comma separated")
public void setProfilers(String profilers) {
this.profilers = profilers;
}
public String getJmhJvmArgs() {
return jmhJvmArgs;
}
@Option(option = "jvmArgs", description = "configure additional JMH JVM arguments, comma separated")
public void setJmhJvmArgs(String jvmArgs) {
this.jmhJvmArgs = jvmArgs;
}
public String getVerify() {
return verify;
}
@Option(option = "verify", description = "run in verify mode")
public void setVerify(String verify) {
this.verify = verify;
}
@TaskAction
public void exec() {
setMain("org.openjdk.jmh.Main");
File resultFile = getProject().file("build/reports/" + getName() + "/result." + format);
if (include != null) {
args(".*" + include + ".*");
}
else if (fullInclude != null) {
args(fullInclude);
}
if(exclude != null) {
args("-e", exclude);
}
if(verify != null) { // execute benchmarks with the minimum amount of execution (only to check if they are working)
System.out.println("Running in verify mode");
args("-f", 1);
args("-wi", 1);
args("-i", 1);
}
args("-foe", "true"); //fail-on-error
args("-v", "NORMAL"); //verbosity [SILENT, NORMAL, EXTRA]
if(profilers != null) {
for (String prof : profilers.split(",")) {
args("-prof", prof);
}
}
args("-jvmArgsPrepend", "-Xmx3072m");
args("-jvmArgsPrepend", "-Xms3072m");
if(jmhJvmArgs != null) {
for(String jvmArg : jmhJvmArgs.split(" ")) {
args("-jvmArgsPrepend", jvmArg);
}
}
args("-rf", format);
args("-rff", resultFile);
System.out.println("\nExecuting JMH with: " + getArgs() + "\n");
resultFile.getParentFile().mkdirs();
super.exec();
}
}