|
| 1 | +package org.zalando.logbook; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.util.concurrent.TimeUnit; |
| 5 | + |
| 6 | +import org.openjdk.jmh.annotations.Benchmark; |
| 7 | +import org.openjdk.jmh.annotations.BenchmarkMode; |
| 8 | +import org.openjdk.jmh.annotations.Fork; |
| 9 | +import org.openjdk.jmh.annotations.Measurement; |
| 10 | +import org.openjdk.jmh.annotations.Mode; |
| 11 | +import org.openjdk.jmh.annotations.Warmup; |
| 12 | +import org.openjdk.jmh.runner.Runner; |
| 13 | +import org.openjdk.jmh.runner.RunnerException; |
| 14 | +import org.openjdk.jmh.runner.options.Options; |
| 15 | +import org.openjdk.jmh.runner.options.OptionsBuilder; |
| 16 | + |
| 17 | +@Fork(value = 1, warmups = 1) |
| 18 | +@Warmup(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS) |
| 19 | +@BenchmarkMode(Mode.Throughput) |
| 20 | +@Measurement(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS) |
| 21 | +public class HeaderBenchmark { |
| 22 | + |
| 23 | + @Benchmark |
| 24 | + public void autoconfigurationRequest(HeaderState headerState) throws IOException { |
| 25 | + headerState.getAutoconfigurationFilter().filter(headerState.getAllRequestHeaders()); |
| 26 | + } |
| 27 | + |
| 28 | + @Benchmark |
| 29 | + public void autoconfigurationResponse(HeaderState headerState) throws IOException { |
| 30 | + headerState.getAutoconfigurationFilter().filter(headerState.getAllResponseHeaders()); |
| 31 | + } |
| 32 | + |
| 33 | + @Benchmark |
| 34 | + public void replace1xRequest(HeaderState headerState) throws IOException { |
| 35 | + headerState.getReplaceFilter().filter(headerState.getAllRequestHeaders()); |
| 36 | + } |
| 37 | + |
| 38 | + @Benchmark |
| 39 | + public void replace1xResponse(HeaderState headerState) throws IOException { |
| 40 | + headerState.getReplaceFilter().filter(headerState.getAllResponseHeaders()); |
| 41 | + } |
| 42 | + |
| 43 | + @Benchmark |
| 44 | + public void replace2xRequest(HeaderState headerState) throws IOException { |
| 45 | + headerState.getReplace2xFilter().filter(headerState.getAllRequestHeaders()); |
| 46 | + } |
| 47 | + |
| 48 | + @Benchmark |
| 49 | + public void replace2xResponse(HeaderState headerState) throws IOException { |
| 50 | + headerState.getReplace2xFilter().filter(headerState.getAllResponseHeaders()); |
| 51 | + } |
| 52 | + |
| 53 | + @Benchmark |
| 54 | + public void replace2xResponseShopify(HeaderState headerState) throws IOException { |
| 55 | + headerState.getReplace2xFilter().filter(headerState.getShopifyResponseHeaders()); |
| 56 | + } |
| 57 | + |
| 58 | + public static void main(String[] args) throws RunnerException { |
| 59 | + Options options = new OptionsBuilder().include(HeaderBenchmark.class.getSimpleName()) |
| 60 | + .forks(1).build(); |
| 61 | + new Runner(options).run(); |
| 62 | + } |
| 63 | +} |
0 commit comments