20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 package org.graalvm.compiler.microbenchmarks.lir; |
23 package org.graalvm.compiler.microbenchmarks.lir; |
24 |
24 |
25 import java.util.HashMap; |
25 import org.graalvm.compiler.lir.gen.LIRGenerationResult; |
|
26 import org.graalvm.compiler.microbenchmarks.graal.GraalBenchmark; |
|
27 import org.openjdk.jmh.annotations.Benchmark; |
|
28 import org.openjdk.jmh.annotations.Measurement; |
|
29 import org.openjdk.jmh.annotations.Param; |
|
30 import org.openjdk.jmh.annotations.Warmup; |
26 |
31 |
27 import org.openjdk.jmh.annotations.Benchmark; |
32 @Warmup(iterations = 10) |
28 |
33 @Measurement(iterations = 10) |
29 import org.graalvm.compiler.lir.gen.LIRGenerationResult; |
|
30 import org.graalvm.compiler.lir.phases.LIRSuites; |
|
31 import org.graalvm.compiler.microbenchmarks.graal.GraalBenchmark; |
|
32 import org.graalvm.compiler.microbenchmarks.graal.util.MethodSpec; |
|
33 |
|
34 public class RegisterAllocationTimeBenchmark extends GraalBenchmark { |
34 public class RegisterAllocationTimeBenchmark extends GraalBenchmark { |
35 |
35 |
36 // Checkstyle: stop method name check |
36 public static class State extends GraalCompilerState.AllocationStage { |
37 public static class LSRA_Allocation extends GraalCompilerState.AllocationStage { |
37 @MethodDescString @Param({ |
38 @SuppressWarnings("try") |
38 "java.lang.String#equals", |
39 @Override |
39 "java.util.HashMap#computeIfAbsent" |
40 protected LIRSuites createLIRSuites() { |
40 }) public String method; |
41 return super.createLIRSuites(); |
|
42 } |
|
43 } |
|
44 |
|
45 @MethodSpec(declaringClass = String.class, name = "equals") |
|
46 public static class LSRA_StringEquals extends LSRA_Allocation { |
|
47 } |
|
48 |
|
49 @MethodSpec(declaringClass = HashMap.class, name = "computeIfAbsent") |
|
50 public static class LSRA_HashMapComputeIfAbsent extends LSRA_Allocation { |
|
51 } |
41 } |
52 |
42 |
53 @Benchmark |
43 @Benchmark |
54 public LIRGenerationResult lsra_STRING_equals(LSRA_StringEquals s) { |
44 public LIRGenerationResult allocateRegisters(State s) { |
55 return s.compile(); |
45 return s.compile(); |
56 } |
46 } |
57 |
|
58 @Benchmark |
|
59 public LIRGenerationResult lsra_HASHMAP_computeIfAbsent(LSRA_HashMapComputeIfAbsent s) { |
|
60 return s.compile(); |
|
61 } |
|
62 |
|
63 public static class TraceRA_Allocation extends GraalCompilerState.AllocationStage { |
|
64 @SuppressWarnings("try") |
|
65 @Override |
|
66 protected LIRSuites createLIRSuites() { |
|
67 return super.createLIRSuites(); |
|
68 } |
|
69 } |
|
70 |
|
71 @MethodSpec(declaringClass = String.class, name = "equals") |
|
72 public static class TraceRA_StringEquals extends TraceRA_Allocation { |
|
73 } |
|
74 |
|
75 @MethodSpec(declaringClass = HashMap.class, name = "computeIfAbsent") |
|
76 public static class TraceRA_HashMapComputeIfAbsent extends TraceRA_Allocation { |
|
77 } |
|
78 |
|
79 @Benchmark |
|
80 public LIRGenerationResult tracera_STRING_equals(TraceRA_StringEquals s) { |
|
81 return s.compile(); |
|
82 } |
|
83 |
|
84 @Benchmark |
|
85 public LIRGenerationResult tracera_HASHMAP_computeIfAbsent(TraceRA_HashMapComputeIfAbsent s) { |
|
86 return s.compile(); |
|
87 } |
|
88 // Checkstyle: resume method name check |
|
89 } |
47 } |