| Benchmark | 25 |ops/sec* | 26 |B/op* | 27 ||
|---|---|---|---|
| liteLogstashLayout4GelfLayout | 32 |1,517,062 | 33 |▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (100%) | 34 |0.0 | 35 |
| liteLogstashLayout4EcsLayout | 38 |1,196,255 | 39 |▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (79%) | 40 |0.0 | 41 |
| liteGelfLayout | 44 |1,184,922 | 45 |▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ (78%) | 46 |0.0 | 47 |
| liteLogstashLayout4JsonLayout | 50 |870,012 | 51 |▉▉▉▉▉▉▉▉▉▉▉ (57%) | 52 |0.0 | 53 |
| liteEcsLayout | 56 |836,648 | 57 |▉▉▉▉▉▉▉▉▉▉▉ (55%) | 58 |0.0 | 59 |
| liteDefaultJsonLayout | 62 |506,985 | 63 |▉▉▉▉▉▉▉ (33%) | 64 |5,331,680.0 | 65 |
| liteCustomJsonLayout | 68 |446,243 | 69 |▉▉▉▉▉▉ (29%) | 70 |5,740,400.0 | 71 |
| fullLogstashLayout4JsonLayout | 74 |118,294 | 75 |▉▉ (8%) | 76 |104,000.1 | 77 |
| fullLogstashLayout4GelfLayout | 80 |73,102 | 81 |▉ (5%) | 82 |35,663,200.3 | 83 |
| fullLogstashLayout4EcsLayout | 86 |60,569 | 87 |▉ (4%) | 88 |35,631,200.4 | 89 |
| fullEcsLayout | 92 |27,887 | 93 |▉ (2%) | 94 |46,479,200.5 | 95 |
| fullGelfLayout | 98 |21,458 | 99 |▉ (1%) | 100 |58,911,200.7 | 101 |
| fullDefaultJsonLayout | 104 |13,513 | 105 |▉ (1%) | 106 |234,102,401.5 | 107 |
| fullCustomJsonLayout | 110 |13,511 | 111 |▉ (1%) | 112 |234,238,401.5 | 113 |
117 | * 99th percentile 118 |
119 || Benchmark | 133 |ops/sec* | 134 |B/op* | 135 ||
|---|---|---|---|
| {} | 143 |{} | 144 |{} | 145 |{} | 146 |
156 | * 99th percentile 157 |
158 |java.class.path property used by JMH.
41 | * @see How to Run a JMH Benchmark in Maven Using exec:java Instead of exec:exec
42 | */
43 | private static void fixJavaClassPath() {
44 | URLClassLoader classLoader = (URLClassLoader) LogstashLayoutBenchmark.class.getClassLoader();
45 | StringBuilder classpathBuilder = new StringBuilder();
46 | for (URL url : classLoader.getURLs()) {
47 | String urlPath = url.getPath();
48 | classpathBuilder.append(urlPath).append(File.pathSeparator);
49 | }
50 | String classpath = classpathBuilder.toString();
51 | System.setProperty("java.class.path", classpath);
52 | }
53 |
54 | private static void enableJsonOutput(ChainedOptionsBuilder optionsBuilder) {
55 | String jsonOutputFile = System.getProperty("log4j2.logstashLayoutBenchmark.jsonOutputFile");
56 | if (jsonOutputFile != null) {
57 | optionsBuilder
58 | .resultFormat(ResultFormatType.JSON)
59 | .result(jsonOutputFile);
60 | }
61 | }
62 |
63 | @Benchmark
64 | public static int fullLogstashLayout4JsonLayout(LogstashLayoutBenchmarkState state) {
65 | return benchmark(state.getLogstashLayout4JsonLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
66 | }
67 |
68 | @Benchmark
69 | public static int liteLogstashLayout4JsonLayout(LogstashLayoutBenchmarkState state) {
70 | return benchmark(state.getLogstashLayout4JsonLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
71 | }
72 |
73 | @Benchmark
74 | public static int fullLogstashLayout4EcsLayout(LogstashLayoutBenchmarkState state) {
75 | return benchmark(state.getLogstashLayout4EcsLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
76 | }
77 |
78 | @Benchmark
79 | public static int liteLogstashLayout4EcsLayout(LogstashLayoutBenchmarkState state) {
80 | return benchmark(state.getLogstashLayout4EcsLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
81 | }
82 |
83 | @Benchmark
84 | public static int fullLogstashLayout4GelfLayout(LogstashLayoutBenchmarkState state) {
85 | return benchmark(state.getLogstashLayout4GelfLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
86 | }
87 |
88 | @Benchmark
89 | public static int liteLogstashLayout4GelfLayout(LogstashLayoutBenchmarkState state) {
90 | return benchmark(state.getLogstashLayout4GelfLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
91 | }
92 |
93 | @Benchmark
94 | public static int fullDefaultJsonLayout(LogstashLayoutBenchmarkState state) {
95 | return benchmark(state.getDefaultJsonLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
96 | }
97 |
98 | @Benchmark
99 | public static int liteDefaultJsonLayout(LogstashLayoutBenchmarkState state) {
100 | return benchmark(state.getDefaultJsonLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
101 | }
102 |
103 | @Benchmark
104 | public static int fullCustomJsonLayout(LogstashLayoutBenchmarkState state) {
105 | return benchmark(state.getCustomJsonLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
106 | }
107 |
108 | @Benchmark
109 | public static int liteCustomJsonLayout(LogstashLayoutBenchmarkState state) {
110 | return benchmark(state.getCustomJsonLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
111 | }
112 |
113 | @Benchmark
114 | public static int fullEcsLayout(LogstashLayoutBenchmarkState state) {
115 | return benchmark(state.getEcsLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
116 | }
117 |
118 | @Benchmark
119 | public static int liteEcsLayout(LogstashLayoutBenchmarkState state) {
120 | return benchmark(state.getEcsLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
121 | }
122 |
123 | @Benchmark
124 | public static int fullGelfLayout(LogstashLayoutBenchmarkState state) {
125 | return benchmark(state.getGelfLayout(), state.getFullLogEvents(), state.getByteBufferDestination());
126 | }
127 |
128 | @Benchmark
129 | public static int liteGelfLayout(LogstashLayoutBenchmarkState state) {
130 | return benchmark(state.getGelfLayout(), state.getLiteLogEvents(), state.getByteBufferDestination());
131 | }
132 |
133 | private static int benchmark(Layout