-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathWebClientBenchmark.java
44 lines (37 loc) · 1.34 KB
/
WebClientBenchmark.java
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
package jmh.benchmarks;
import jenkins.benchmark.jmh.JmhBenchmark;
import jenkins.benchmark.jmh.JmhBenchmarkState;
import jmh.JmhJenkinsRule;
import org.jvnet.hudson.test.JenkinsRule;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.infra.Blackhole;
@JmhBenchmark
public class WebClientBenchmark {
public static class JenkinsState extends JmhBenchmarkState {
}
// WebClient is not thread-safe, so use a different WebClient for each thread
@State(Scope.Thread)
public static class ThreadState {
JenkinsRule.WebClient webClient = null;
@Setup(Level.Iteration)
public void setup() throws Exception {
// JQuery UI is 404 from these tests so disable stopping benchmark when it is used.
JmhJenkinsRule j = new JmhJenkinsRule();
webClient = j.createWebClient();
webClient.login("mockUser", "mockUser");
}
@TearDown(Level.Iteration)
public void tearDown() {
webClient.close();
}
}
@Benchmark
public void viewRenderBenchmark(JenkinsState state, ThreadState threadState, Blackhole blackhole) throws Exception {
blackhole.consume(threadState.webClient.goTo(""));
}
}