-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
73 lines (62 loc) · 2.08 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
plugins {
id 'java'
}
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
version = '1-SNAPSHOT'
java {
sourceCompatibility = JavaVersion.VERSION_11
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add("-Xlint:deprecation")
}
dependencies {
implementation(libs.commons.cli)
implementation(libs.slf4j.api)
implementation(libs.slf4j.nop)
implementation(libs.httpclient4)
implementation(libs.httpasyncclient4)
implementation(libs.httpclient5)
implementation(libs.jetty)
implementation(libs.okhttp)
implementation(libs.spring.webflux2) {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
def targetUri = project.hasProperty('benchmark.target-uri') ? project.'benchmark.target-uri' : null
def n = project.hasProperty('benchmark.requests') ? project.'benchmark.requests' : 2000
def c = project.hasProperty('benchmark.concurrency') ? project.'benchmark.concurrency' : 2
def content = project.hasProperty('benchmark.content-file') ? project.'benchmark.content-file' : null
def contentType = project.hasProperty('benchmark.content-type') ? project.'benchmark.content-type' : 'text/plain'
task benchmark(dependsOn: 'classes') {
doLast {
def agents = [
'JREHttpUrlConnection',
'ApacheHttpClientV4',
'ApacheHttpClientV5',
'JRE11HttpClient',
'JettyHttpClientV11',
'OkHttpClientV4',
'SpringWebFluxV2',
'ApacheHttpAsyncClientV4',
'ApacheHttpAsyncClientV5',
]
def params = ['-n', "${n}", '-c', "${c}", '-k']
if (content) {
params += ['-p', content, '-t', contentType]
}
params += targetUri
agents.each { agent ->
javaexec {
main = "com.ok2c.http.client.benchmark.${agent}"
classpath = sourceSets.main.runtimeClasspath
args = params
}
sleep(2000)
}
}
}
defaultTasks 'clean', 'benchmark'