forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChiBenchmark.java
More file actions
55 lines (44 loc) · 1.34 KB
/
ChiBenchmark.java
File metadata and controls
55 lines (44 loc) · 1.34 KB
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
package io.jooby.internal;
import io.jooby.Route;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.TimeUnit;
@Fork(5)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class ChiBenchmark {
private Chi router;
@Setup
public void setup() {
router = new Chi();
router.insert(route("GET", "/plaintext"));
router.insert(route("GET", "/articles/{id}"));
router.insert(route("GET", "/articles/{id}/edit"));
}
private Route route(String method, String pattern) {
return new Route(method, pattern, ctx -> "").setReturnType(String.class);
}
@Benchmark
public void _plaintext() {
router.find("GET", "/plaintext");
}
@Benchmark
public void articles() {
router.find("GET", "/articles/123");
}
@Benchmark
public void articlesEdit() {
router.find("GET", "/articles/123/edit");
}
}