Last active
April 3, 2016 22:24
-
-
Save QIvan/01436632ba0f85db06ec8427347a6b5c to your computer and use it in GitHub Desktop.
Switch vs Map vs If-else with Strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Benchmark (arg) Mode Samples Score Score error Units | |
m.MyBenchmark.baseline 4000 avgt 200 3.054 0.012 ns/op | |
m.MyBenchmark.baseline 5501 avgt 200 3.062 0.013 ns/op | |
m.MyBenchmark.baseline 1000 avgt 200 3.076 0.012 ns/op | |
m.MyBenchmark.baseline 3000 avgt 200 3.074 0.012 ns/op | |
m.MyBenchmark.baseline 6000 avgt 200 3.059 0.012 ns/op | |
m.MyBenchmark.ifTest 4000 avgt 200 21.889 0.154 ns/op | |
m.MyBenchmark.ifTest 5501 avgt 200 32.324 0.200 ns/op | |
m.MyBenchmark.ifTest 1000 avgt 200 8.505 0.042 ns/op | |
m.MyBenchmark.ifTest 3000 avgt 200 16.306 0.104 ns/op | |
m.MyBenchmark.ifTest 6000 avgt 200 32.754 0.219 ns/op | |
m.MyBenchmark.mapTest 4000 avgt 200 9.949 0.064 ns/op | |
m.MyBenchmark.mapTest 5501 avgt 200 4.976 0.030 ns/op | |
m.MyBenchmark.mapTest 1000 avgt 200 9.910 0.061 ns/op | |
m.MyBenchmark.mapTest 3000 avgt 200 9.872 0.066 ns/op | |
m.MyBenchmark.mapTest 6000 avgt 200 10.810 0.070 ns/op | |
m.MyBenchmark.switchTest 4000 avgt 200 14.344 0.085 ns/op | |
m.MyBenchmark.switchTest 5501 avgt 200 10.328 0.058 ns/op | |
m.MyBenchmark.switchTest 1000 avgt 200 14.528 0.091 ns/op | |
m.MyBenchmark.switchTest 3000 avgt 200 11.681 0.067 ns/op | |
m.MyBenchmark.switchTest 6000 avgt 200 14.699 0.080 ns/op |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openjdk.jmh.annotations.*; | |
import org.openjdk.jmh.runner.Runner; | |
import org.openjdk.jmh.runner.RunnerException; | |
import org.openjdk.jmh.runner.options.Options; | |
import org.openjdk.jmh.runner.options.OptionsBuilder; | |
import java.util.HashMap; | |
import java.util.concurrent.TimeUnit; | |
@State(Scope.Thread) | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
public class MyBenchmark { | |
final HashMap<String, String> map = new HashMap<String, String>() { | |
{ | |
put("1", "a"); | |
put("10", "b"); | |
put("100", "c"); | |
put("1000", "d"); | |
put("2000", "e"); | |
put("2500", "f"); | |
put("3000", "g"); | |
put("3500", "h"); | |
put("4000", "i"); | |
put("4500", "j"); | |
put("5000", "k"); | |
put("5500", "l"); | |
put("6000", "m"); | |
} | |
}; | |
@Param({"4000", "5501", "1000", "3000", "6000"}) | |
public String arg; | |
@Benchmark | |
public String baseline() { | |
return "a"; | |
} | |
@Benchmark | |
public String ifTest() { | |
if (arg.equals("1")) { | |
return "a"; | |
} else if (arg.equals("10")) { | |
return "b"; | |
} else if (arg.equals("100")) { | |
return "c"; | |
} else if (arg.equals("1000")) { | |
return "d"; | |
} else if (arg.equals("2000")) { | |
return "e"; | |
} else if (arg.equals("2500")) { | |
return "f"; | |
} else if (arg.equals("3000")) { | |
return "g"; | |
} else if (arg.equals("3500")) { | |
return "h"; | |
} else if (arg.equals("4000")) { | |
return "i"; | |
} else if (arg.equals("4500")) { | |
return "j"; | |
} else if (arg.equals("5000")) { | |
return "k"; | |
} else if (arg.equals("5500")) { | |
return "l"; | |
} else if (arg.equals("6000")) { | |
return "m"; | |
} else { | |
return null; | |
} | |
} | |
@Benchmark | |
public String switchTest() { | |
switch (arg) { | |
case "1": | |
return "a"; | |
case "10": | |
return "b"; | |
case "100": | |
return "c"; | |
case "1000": | |
return "d"; | |
case "2000": | |
return "e"; | |
case "2500": | |
return "f"; | |
case "3000": | |
return "g"; | |
case "3500": | |
return "h"; | |
case "4000": | |
return "i"; | |
case "4500": | |
return "j"; | |
case "5000": | |
return "k"; | |
case "5500": | |
return "l"; | |
case "6000": | |
return "m"; | |
default: | |
return null; | |
} | |
} | |
@Benchmark | |
public String mapTest() { | |
return map.get(arg); | |
} | |
public static void main(String[] args) throws RunnerException { | |
Options opt = new OptionsBuilder() | |
.include(MyBenchmark.class.getSimpleName()) | |
.warmupIterations(20) | |
.measurementIterations(20) | |
.build(); | |
new Runner(opt).run(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Classfile /home/ivan/program/jmh/target/classes/my/MyBenchmark.class | |
Last modified Apr 3, 2016; size 3506 bytes | |
MD5 checksum 43c43b3080eb4dd1251ffc627f33b56c | |
Compiled from "MyBenchmark.java" | |
public class my.MyBenchmark | |
minor version: 0 | |
major version: 52 | |
flags: ACC_PUBLIC, ACC_SUPER | |
Constant pool: | |
#1 = Methodref #47.#97 // java/lang/Object."<init>":()V | |
#2 = Class #98 // my/MyBenchmark$1 | |
#3 = Methodref #2.#99 // my/MyBenchmark$1."<init>":(Lmy/MyBenchmark;)V | |
#4 = Fieldref #38.#100 // my/MyBenchmark.map:Ljava/util/HashMap; | |
#5 = String #101 // a | |
#6 = Fieldref #38.#102 // my/MyBenchmark.arg:Ljava/lang/String; | |
#7 = String #103 // 1 | |
#8 = Methodref #35.#104 // java/lang/String.equals:(Ljava/lang/Object;)Z | |
#9 = String #105 // 10 | |
#10 = String #106 // b | |
#11 = String #107 // 100 | |
#12 = String #108 // c | |
#13 = String #60 // 1000 | |
#14 = String #109 // d | |
#15 = String #110 // 2000 | |
#16 = String #111 // e | |
#17 = String #112 // 2500 | |
#18 = String #113 // f | |
#19 = String #61 // 3000 | |
#20 = String #114 // g | |
#21 = String #115 // 3500 | |
#22 = String #116 // h | |
#23 = String #58 // 4000 | |
#24 = String #117 // i | |
#25 = String #118 // 4500 | |
#26 = String #119 // j | |
#27 = String #120 // 5000 | |
#28 = String #121 // k | |
#29 = String #122 // 5500 | |
#30 = String #123 // l | |
#31 = String #62 // 6000 | |
#32 = String #124 // m | |
#33 = Methodref #35.#125 // java/lang/String.hashCode:()I | |
#34 = Methodref #126.#127 // java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object; | |
#35 = Class #128 // java/lang/String | |
#36 = Class #129 // org/openjdk/jmh/runner/options/OptionsBuilder | |
#37 = Methodref #36.#97 // org/openjdk/jmh/runner/options/OptionsBuilder."<init>":()V | |
#38 = Class #130 // my/MyBenchmark | |
#39 = Methodref #131.#132 // java/lang/Class.getSimpleName:()Ljava/lang/String; | |
#40 = Methodref #36.#133 // org/openjdk/jmh/runner/options/OptionsBuilder.include:(Ljava/lang/String;)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#41 = InterfaceMethodref #134.#135 // org/openjdk/jmh/runner/options/ChainedOptionsBuilder.warmupIterations:(I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#42 = InterfaceMethodref #134.#136 // org/openjdk/jmh/runner/options/ChainedOptionsBuilder.measurementIterations:(I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#43 = InterfaceMethodref #134.#137 // org/openjdk/jmh/runner/options/ChainedOptionsBuilder.build:()Lorg/openjdk/jmh/runner/options/Options; | |
#44 = Class #138 // org/openjdk/jmh/runner/Runner | |
#45 = Methodref #44.#139 // org/openjdk/jmh/runner/Runner."<init>":(Lorg/openjdk/jmh/runner/options/Options;)V | |
#46 = Methodref #44.#140 // org/openjdk/jmh/runner/Runner.run:()Ljava/util/Collection; | |
#47 = Class #141 // java/lang/Object | |
#48 = Utf8 InnerClasses | |
#49 = Utf8 map | |
#50 = Utf8 Ljava/util/HashMap; | |
#51 = Utf8 Signature | |
#52 = Utf8 Ljava/util/HashMap<Ljava/lang/String;Ljava/lang/String;>; | |
#53 = Utf8 arg | |
#54 = Utf8 Ljava/lang/String; | |
#55 = Utf8 RuntimeVisibleAnnotations | |
#56 = Utf8 Lorg/openjdk/jmh/annotations/Param; | |
#57 = Utf8 value | |
#58 = Utf8 4000 | |
#59 = Utf8 5501 | |
#60 = Utf8 1000 | |
#61 = Utf8 3000 | |
#62 = Utf8 6000 | |
#63 = Utf8 <init> | |
#64 = Utf8 ()V | |
#65 = Utf8 Code | |
#66 = Utf8 LineNumberTable | |
#67 = Utf8 LocalVariableTable | |
#68 = Utf8 this | |
#69 = Utf8 Lmy/MyBenchmark; | |
#70 = Utf8 baseline | |
#71 = Utf8 ()Ljava/lang/String; | |
#72 = Utf8 Lorg/openjdk/jmh/annotations/Benchmark; | |
#73 = Utf8 ifTest | |
#74 = Utf8 StackMapTable | |
#75 = Utf8 switchTest | |
#76 = Class #128 // java/lang/String | |
#77 = Utf8 mapTest | |
#78 = Utf8 main | |
#79 = Utf8 ([Ljava/lang/String;)V | |
#80 = Utf8 args | |
#81 = Utf8 [Ljava/lang/String; | |
#82 = Utf8 opt | |
#83 = Utf8 Lorg/openjdk/jmh/runner/options/Options; | |
#84 = Utf8 Exceptions | |
#85 = Class #142 // org/openjdk/jmh/runner/RunnerException | |
#86 = Utf8 SourceFile | |
#87 = Utf8 MyBenchmark.java | |
#88 = Utf8 Lorg/openjdk/jmh/annotations/State; | |
#89 = Utf8 Lorg/openjdk/jmh/annotations/Scope; | |
#90 = Utf8 Thread | |
#91 = Utf8 Lorg/openjdk/jmh/annotations/BenchmarkMode; | |
#92 = Utf8 Lorg/openjdk/jmh/annotations/Mode; | |
#93 = Utf8 AverageTime | |
#94 = Utf8 Lorg/openjdk/jmh/annotations/OutputTimeUnit; | |
#95 = Utf8 Ljava/util/concurrent/TimeUnit; | |
#96 = Utf8 NANOSECONDS | |
#97 = NameAndType #63:#64 // "<init>":()V | |
#98 = Utf8 my/MyBenchmark$1 | |
#99 = NameAndType #63:#143 // "<init>":(Lmy/MyBenchmark;)V | |
#100 = NameAndType #49:#50 // map:Ljava/util/HashMap; | |
#101 = Utf8 a | |
#102 = NameAndType #53:#54 // arg:Ljava/lang/String; | |
#103 = Utf8 1 | |
#104 = NameAndType #144:#145 // equals:(Ljava/lang/Object;)Z | |
#105 = Utf8 10 | |
#106 = Utf8 b | |
#107 = Utf8 100 | |
#108 = Utf8 c | |
#109 = Utf8 d | |
#110 = Utf8 2000 | |
#111 = Utf8 e | |
#112 = Utf8 2500 | |
#113 = Utf8 f | |
#114 = Utf8 g | |
#115 = Utf8 3500 | |
#116 = Utf8 h | |
#117 = Utf8 i | |
#118 = Utf8 4500 | |
#119 = Utf8 j | |
#120 = Utf8 5000 | |
#121 = Utf8 k | |
#122 = Utf8 5500 | |
#123 = Utf8 l | |
#124 = Utf8 m | |
#125 = NameAndType #146:#147 // hashCode:()I | |
#126 = Class #148 // java/util/HashMap | |
#127 = NameAndType #149:#150 // get:(Ljava/lang/Object;)Ljava/lang/Object; | |
#128 = Utf8 java/lang/String | |
#129 = Utf8 org/openjdk/jmh/runner/options/OptionsBuilder | |
#130 = Utf8 my/MyBenchmark | |
#131 = Class #151 // java/lang/Class | |
#132 = NameAndType #152:#71 // getSimpleName:()Ljava/lang/String; | |
#133 = NameAndType #153:#154 // include:(Ljava/lang/String;)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#134 = Class #155 // org/openjdk/jmh/runner/options/ChainedOptionsBuilder | |
#135 = NameAndType #156:#157 // warmupIterations:(I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#136 = NameAndType #158:#157 // measurementIterations:(I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#137 = NameAndType #159:#160 // build:()Lorg/openjdk/jmh/runner/options/Options; | |
#138 = Utf8 org/openjdk/jmh/runner/Runner | |
#139 = NameAndType #63:#161 // "<init>":(Lorg/openjdk/jmh/runner/options/Options;)V | |
#140 = NameAndType #162:#163 // run:()Ljava/util/Collection; | |
#141 = Utf8 java/lang/Object | |
#142 = Utf8 org/openjdk/jmh/runner/RunnerException | |
#143 = Utf8 (Lmy/MyBenchmark;)V | |
#144 = Utf8 equals | |
#145 = Utf8 (Ljava/lang/Object;)Z | |
#146 = Utf8 hashCode | |
#147 = Utf8 ()I | |
#148 = Utf8 java/util/HashMap | |
#149 = Utf8 get | |
#150 = Utf8 (Ljava/lang/Object;)Ljava/lang/Object; | |
#151 = Utf8 java/lang/Class | |
#152 = Utf8 getSimpleName | |
#153 = Utf8 include | |
#154 = Utf8 (Ljava/lang/String;)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#155 = Utf8 org/openjdk/jmh/runner/options/ChainedOptionsBuilder | |
#156 = Utf8 warmupIterations | |
#157 = Utf8 (I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
#158 = Utf8 measurementIterations | |
#159 = Utf8 build | |
#160 = Utf8 ()Lorg/openjdk/jmh/runner/options/Options; | |
#161 = Utf8 (Lorg/openjdk/jmh/runner/options/Options;)V | |
#162 = Utf8 run | |
#163 = Utf8 ()Ljava/util/Collection; | |
{ | |
final java.util.HashMap<java.lang.String, java.lang.String> map; | |
descriptor: Ljava/util/HashMap; | |
flags: ACC_FINAL | |
Signature: #52 // Ljava/util/HashMap<Ljava/lang/String;Ljava/lang/String;>; | |
public java.lang.String arg; | |
descriptor: Ljava/lang/String; | |
flags: ACC_PUBLIC | |
RuntimeVisibleAnnotations: | |
0: #56(#57=[s#58,s#59,s#60,s#61,s#62]) | |
public my.MyBenchmark(); | |
descriptor: ()V | |
flags: ACC_PUBLIC | |
Code: | |
stack=4, locals=1, args_size=1 | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: aload_0 | |
5: new #2 // class my/MyBenchmark$1 | |
8: dup | |
9: aload_0 | |
10: invokespecial #3 // Method my/MyBenchmark$1."<init>":(Lmy/MyBenchmark;)V | |
13: putfield #4 // Field map:Ljava/util/HashMap; | |
16: return | |
LineNumberTable: | |
line 40: 0 | |
line 42: 4 | |
LocalVariableTable: | |
Start Length Slot Name Signature | |
0 17 0 this Lmy/MyBenchmark; | |
public java.lang.String baseline(); | |
descriptor: ()Ljava/lang/String; | |
flags: ACC_PUBLIC | |
Code: | |
stack=1, locals=1, args_size=1 | |
0: ldc #5 // String a | |
2: areturn | |
LineNumberTable: | |
line 65: 0 | |
LocalVariableTable: | |
Start Length Slot Name Signature | |
0 3 0 this Lmy/MyBenchmark; | |
RuntimeVisibleAnnotations: | |
0: #72() | |
public java.lang.String ifTest(); | |
descriptor: ()Ljava/lang/String; | |
flags: ACC_PUBLIC | |
Code: | |
stack=2, locals=1, args_size=1 | |
0: aload_0 | |
1: getfield #6 // Field arg:Ljava/lang/String; | |
4: ldc #7 // String 1 | |
6: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
9: ifeq 15 | |
12: ldc #5 // String a | |
14: areturn | |
15: aload_0 | |
16: getfield #6 // Field arg:Ljava/lang/String; | |
19: ldc #9 // String 10 | |
21: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
24: ifeq 30 | |
27: ldc #10 // String b | |
29: areturn | |
30: aload_0 | |
31: getfield #6 // Field arg:Ljava/lang/String; | |
34: ldc #11 // String 100 | |
36: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
39: ifeq 45 | |
42: ldc #12 // String c | |
44: areturn | |
45: aload_0 | |
46: getfield #6 // Field arg:Ljava/lang/String; | |
49: ldc #13 // String 1000 | |
51: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
54: ifeq 60 | |
57: ldc #14 // String d | |
59: areturn | |
60: aload_0 | |
61: getfield #6 // Field arg:Ljava/lang/String; | |
64: ldc #15 // String 2000 | |
66: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
69: ifeq 75 | |
72: ldc #16 // String e | |
74: areturn | |
75: aload_0 | |
76: getfield #6 // Field arg:Ljava/lang/String; | |
79: ldc #17 // String 2500 | |
81: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
84: ifeq 90 | |
87: ldc #18 // String f | |
89: areturn | |
90: aload_0 | |
91: getfield #6 // Field arg:Ljava/lang/String; | |
94: ldc #19 // String 3000 | |
96: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
99: ifeq 105 | |
102: ldc #20 // String g | |
104: areturn | |
105: aload_0 | |
106: getfield #6 // Field arg:Ljava/lang/String; | |
109: ldc #21 // String 3500 | |
111: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
114: ifeq 120 | |
117: ldc #22 // String h | |
119: areturn | |
120: aload_0 | |
121: getfield #6 // Field arg:Ljava/lang/String; | |
124: ldc #23 // String 4000 | |
126: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
129: ifeq 135 | |
132: ldc #24 // String i | |
134: areturn | |
135: aload_0 | |
136: getfield #6 // Field arg:Ljava/lang/String; | |
139: ldc #25 // String 4500 | |
141: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
144: ifeq 150 | |
147: ldc #26 // String j | |
149: areturn | |
150: aload_0 | |
151: getfield #6 // Field arg:Ljava/lang/String; | |
154: ldc #27 // String 5000 | |
156: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
159: ifeq 165 | |
162: ldc #28 // String k | |
164: areturn | |
165: aload_0 | |
166: getfield #6 // Field arg:Ljava/lang/String; | |
169: ldc #29 // String 5500 | |
171: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
174: ifeq 180 | |
177: ldc #30 // String l | |
179: areturn | |
180: aload_0 | |
181: getfield #6 // Field arg:Ljava/lang/String; | |
184: ldc #31 // String 6000 | |
186: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
189: ifeq 195 | |
192: ldc #32 // String m | |
194: areturn | |
195: aconst_null | |
196: areturn | |
LineNumberTable: | |
line 70: 0 | |
line 71: 12 | |
line 72: 15 | |
line 73: 27 | |
line 74: 30 | |
line 75: 42 | |
line 76: 45 | |
line 77: 57 | |
line 78: 60 | |
line 79: 72 | |
line 80: 75 | |
line 81: 87 | |
line 82: 90 | |
line 83: 102 | |
line 84: 105 | |
line 85: 117 | |
line 86: 120 | |
line 87: 132 | |
line 88: 135 | |
line 89: 147 | |
line 90: 150 | |
line 91: 162 | |
line 92: 165 | |
line 93: 177 | |
line 94: 180 | |
line 95: 192 | |
line 97: 195 | |
LocalVariableTable: | |
Start Length Slot Name Signature | |
0 197 0 this Lmy/MyBenchmark; | |
StackMapTable: number_of_entries = 13 | |
frame_type = 15 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
RuntimeVisibleAnnotations: | |
0: #72() | |
public java.lang.String switchTest(); | |
descriptor: ()Ljava/lang/String; | |
flags: ACC_PUBLIC | |
Code: | |
stack=2, locals=3, args_size=1 | |
0: aload_0 | |
1: getfield #6 // Field arg:Ljava/lang/String; | |
4: astore_1 | |
5: iconst_m1 | |
6: istore_2 | |
7: aload_1 | |
8: invokevirtual #33 // Method java/lang/String.hashCode:()I | |
11: lookupswitch { // 13 | |
49: 124 | |
1567: 138 | |
48625: 152 | |
1507423: 166 | |
1537214: 180 | |
1542019: 194 | |
1567005: 208 | |
1571810: 223 | |
1596796: 238 | |
1601601: 253 | |
1626587: 268 | |
1631392: 283 | |
1656378: 298 | |
default: 310 | |
} | |
124: aload_1 | |
125: ldc #7 // String 1 | |
127: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
130: ifeq 310 | |
133: iconst_0 | |
134: istore_2 | |
135: goto 310 | |
138: aload_1 | |
139: ldc #9 // String 10 | |
141: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
144: ifeq 310 | |
147: iconst_1 | |
148: istore_2 | |
149: goto 310 | |
152: aload_1 | |
153: ldc #11 // String 100 | |
155: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
158: ifeq 310 | |
161: iconst_2 | |
162: istore_2 | |
163: goto 310 | |
166: aload_1 | |
167: ldc #13 // String 1000 | |
169: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
172: ifeq 310 | |
175: iconst_3 | |
176: istore_2 | |
177: goto 310 | |
180: aload_1 | |
181: ldc #15 // String 2000 | |
183: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
186: ifeq 310 | |
189: iconst_4 | |
190: istore_2 | |
191: goto 310 | |
194: aload_1 | |
195: ldc #17 // String 2500 | |
197: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
200: ifeq 310 | |
203: iconst_5 | |
204: istore_2 | |
205: goto 310 | |
208: aload_1 | |
209: ldc #19 // String 3000 | |
211: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
214: ifeq 310 | |
217: bipush 6 | |
219: istore_2 | |
220: goto 310 | |
223: aload_1 | |
224: ldc #21 // String 3500 | |
226: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
229: ifeq 310 | |
232: bipush 7 | |
234: istore_2 | |
235: goto 310 | |
238: aload_1 | |
239: ldc #23 // String 4000 | |
241: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
244: ifeq 310 | |
247: bipush 8 | |
249: istore_2 | |
250: goto 310 | |
253: aload_1 | |
254: ldc #25 // String 4500 | |
256: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
259: ifeq 310 | |
262: bipush 9 | |
264: istore_2 | |
265: goto 310 | |
268: aload_1 | |
269: ldc #27 // String 5000 | |
271: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
274: ifeq 310 | |
277: bipush 10 | |
279: istore_2 | |
280: goto 310 | |
283: aload_1 | |
284: ldc #29 // String 5500 | |
286: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
289: ifeq 310 | |
292: bipush 11 | |
294: istore_2 | |
295: goto 310 | |
298: aload_1 | |
299: ldc #31 // String 6000 | |
301: invokevirtual #8 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
304: ifeq 310 | |
307: bipush 12 | |
309: istore_2 | |
310: iload_2 | |
311: tableswitch { // 0 to 12 | |
0: 376 | |
1: 379 | |
2: 382 | |
3: 385 | |
4: 388 | |
5: 391 | |
6: 394 | |
7: 397 | |
8: 400 | |
9: 403 | |
10: 406 | |
11: 409 | |
12: 412 | |
default: 415 | |
} | |
376: ldc #5 // String a | |
378: areturn | |
379: ldc #10 // String b | |
381: areturn | |
382: ldc #12 // String c | |
384: areturn | |
385: ldc #14 // String d | |
387: areturn | |
388: ldc #16 // String e | |
390: areturn | |
391: ldc #18 // String f | |
393: areturn | |
394: ldc #20 // String g | |
396: areturn | |
397: ldc #22 // String h | |
399: areturn | |
400: ldc #24 // String i | |
402: areturn | |
403: ldc #26 // String j | |
405: areturn | |
406: ldc #28 // String k | |
408: areturn | |
409: ldc #30 // String l | |
411: areturn | |
412: ldc #32 // String m | |
414: areturn | |
415: aconst_null | |
416: areturn | |
LineNumberTable: | |
line 104: 0 | |
line 106: 376 | |
line 108: 379 | |
line 110: 382 | |
line 112: 385 | |
line 114: 388 | |
line 116: 391 | |
line 118: 394 | |
line 120: 397 | |
line 122: 400 | |
line 124: 403 | |
line 126: 406 | |
line 128: 409 | |
line 130: 412 | |
line 132: 415 | |
LocalVariableTable: | |
Start Length Slot Name Signature | |
0 417 0 this Lmy/MyBenchmark; | |
StackMapTable: number_of_entries = 28 | |
frame_type = 253 /* append */ | |
offset_delta = 124 | |
locals = [ class java/lang/String, int ] | |
frame_type = 13 /* same */ | |
frame_type = 13 /* same */ | |
frame_type = 13 /* same */ | |
frame_type = 13 /* same */ | |
frame_type = 13 /* same */ | |
frame_type = 13 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 14 /* same */ | |
frame_type = 11 /* same */ | |
frame_type = 251 /* same_frame_extended */ | |
offset_delta = 65 | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
frame_type = 2 /* same */ | |
RuntimeVisibleAnnotations: | |
0: #72() | |
public java.lang.String mapTest(); | |
descriptor: ()Ljava/lang/String; | |
flags: ACC_PUBLIC | |
Code: | |
stack=2, locals=1, args_size=1 | |
0: aload_0 | |
1: getfield #4 // Field map:Ljava/util/HashMap; | |
4: aload_0 | |
5: getfield #6 // Field arg:Ljava/lang/String; | |
8: invokevirtual #34 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object; | |
11: checkcast #35 // class java/lang/String | |
14: areturn | |
LineNumberTable: | |
line 138: 0 | |
LocalVariableTable: | |
Start Length Slot Name Signature | |
0 15 0 this Lmy/MyBenchmark; | |
RuntimeVisibleAnnotations: | |
0: #72() | |
public static void main(java.lang.String[]) throws org.openjdk.jmh.runner.RunnerException; | |
descriptor: ([Ljava/lang/String;)V | |
flags: ACC_PUBLIC, ACC_STATIC | |
Code: | |
stack=3, locals=2, args_size=1 | |
0: new #36 // class org/openjdk/jmh/runner/options/OptionsBuilder | |
3: dup | |
4: invokespecial #37 // Method org/openjdk/jmh/runner/options/OptionsBuilder."<init>":()V | |
7: ldc #38 // class my/MyBenchmark | |
9: invokevirtual #39 // Method java/lang/Class.getSimpleName:()Ljava/lang/String; | |
12: invokevirtual #40 // Method org/openjdk/jmh/runner/options/OptionsBuilder.include:(Ljava/lang/String;)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
15: bipush 20 | |
17: invokeinterface #41, 2 // InterfaceMethod org/openjdk/jmh/runner/options/ChainedOptionsBuilder.warmupIterations:(I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
22: bipush 20 | |
24: invokeinterface #42, 2 // InterfaceMethod org/openjdk/jmh/runner/options/ChainedOptionsBuilder.measurementIterations:(I)Lorg/openjdk/jmh/runner/options/ChainedOptionsBuilder; | |
29: invokeinterface #43, 1 // InterfaceMethod org/openjdk/jmh/runner/options/ChainedOptionsBuilder.build:()Lorg/openjdk/jmh/runner/options/Options; | |
34: astore_1 | |
35: new #44 // class org/openjdk/jmh/runner/Runner | |
38: dup | |
39: aload_1 | |
40: invokespecial #45 // Method org/openjdk/jmh/runner/Runner."<init>":(Lorg/openjdk/jmh/runner/options/Options;)V | |
43: invokevirtual #46 // Method org/openjdk/jmh/runner/Runner.run:()Ljava/util/Collection; | |
46: pop | |
47: return | |
LineNumberTable: | |
line 143: 0 | |
line 144: 9 | |
line 145: 17 | |
line 146: 24 | |
line 147: 29 | |
line 149: 35 | |
line 150: 47 | |
LocalVariableTable: | |
Start Length Slot Name Signature | |
0 48 0 args [Ljava/lang/String; | |
35 13 1 opt Lorg/openjdk/jmh/runner/options/Options; | |
Exceptions: | |
throws org.openjdk.jmh.runner.RunnerException | |
} | |
SourceFile: "MyBenchmark.java" | |
RuntimeVisibleAnnotations: | |
0: #88(#57=e#89.#90) | |
1: #91(#57=[e#92.#93]) | |
2: #94(#57=e#95.#96) | |
InnerClasses: | |
#2; //class my/MyBenchmark$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment