File tree 1 file changed +14
-1
lines changed
log4j-perf-test/src/main/java/org/apache/logging/log4j/perf/jmh
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 17
17
package org .apache .logging .log4j .perf .jmh ;
18
18
19
19
import java .util .UUID ;
20
+ import org .apache .logging .log4j .core .LogEvent ;
21
+ import org .apache .logging .log4j .core .test .layout .LogEventFixtures ;
20
22
import org .apache .logging .log4j .core .util .UuidUtil ;
21
23
import org .openjdk .jmh .annotations .Benchmark ;
24
+ import org .openjdk .jmh .annotations .Scope ;
25
+ import org .openjdk .jmh .annotations .State ;
22
26
23
27
/**
24
- * Compares random UUID generation with time-based UUID generation .
28
+ * Compares UUID generators .
25
29
*/
26
30
// ============================== HOW TO RUN THIS TEST: ====================================
27
31
//
31
35
// java -jar log4j-perf/target/benchmarks.jar -help
32
36
//
33
37
public class UuidGeneratorBenchmark {
38
+ @ State (Scope .Benchmark )
39
+ public static class UuidGeneratorBenchmarkState {
40
+ private final LogEvent logEvent = LogEventFixtures .createLogEvent ();
41
+ }
34
42
35
43
@ Benchmark
36
44
public UUID base () {
@@ -46,4 +54,9 @@ public UUID randomUUID() {
46
54
public UUID timeBasedUUID () {
47
55
return UuidUtil .getTimeBasedUuid ();
48
56
}
57
+
58
+ @ Benchmark
59
+ public UUID hashBasedUuid (UuidGeneratorBenchmarkState state ) {
60
+ return UuidUtil .getHashBasedUuid (state .logEvent );
61
+ }
49
62
}
You can’t perform that action at this time.
0 commit comments