author | ecaspole |
Fri, 08 Mar 2019 17:45:40 -0500 | |
changeset 54043 | 0324b3756aa2 |
parent 52595 | 16609197022c |
permissions | -rw-r--r-- |
52595
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
1 |
/* |
54043
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
52595
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
4 |
* |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
8 |
* |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
13 |
* accompanied this code). |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
14 |
* |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
18 |
* |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
21 |
* questions. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
22 |
*/ |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
23 |
package org.openjdk.bench.java.lang; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
24 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
25 |
import org.openjdk.jmh.annotations.Benchmark; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
26 |
import org.openjdk.jmh.annotations.BenchmarkMode; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
27 |
import org.openjdk.jmh.annotations.Mode; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
28 |
import org.openjdk.jmh.annotations.OutputTimeUnit; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
29 |
import org.openjdk.jmh.annotations.Scope; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
30 |
import org.openjdk.jmh.annotations.Setup; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
31 |
import org.openjdk.jmh.annotations.State; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
32 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
33 |
import java.util.concurrent.TimeUnit; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
34 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
35 |
@BenchmarkMode(Mode.AverageTime) |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
36 |
@OutputTimeUnit(TimeUnit.NANOSECONDS) |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
37 |
@State(Scope.Thread) |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
38 |
public class StringIndexOf { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
39 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
40 |
private String dataString; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
41 |
private String searchString; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
42 |
private String dataStringBig; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
43 |
private String searchStringBig; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
44 |
private String data; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
45 |
private String sub; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
46 |
private String shortSub1; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
47 |
private String data2; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
48 |
private String shortSub2; |
54043
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
49 |
private String string16Short; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
50 |
private String string16Medium; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
51 |
private String string16Long; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
52 |
private char searchChar; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
53 |
private char searchChar16; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
54 |
private String searchString16; |
52595
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
55 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
56 |
@Setup |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
57 |
public void setup() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
58 |
dataString = "ngdfilsoscargfdgf"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
59 |
searchString = "oscar"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
60 |
dataStringBig = "2937489745890797905764956790452976742965790437698498409583479067ngdcapaapapapasdkajdlkajskldjaslkjdlkasjdsalkjas"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
61 |
searchStringBig = "capaapapapasdkajdlkajskldjaslkjdlkasjdsalk"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
62 |
data = "0000100101010010110101010010101110101001110110101010010101010010000010111010101010101010100010010101110111010101101010100010010100001010111111100001010101001010100001010101001010101010111010010101010101010101010101010"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
63 |
sub = "10101010"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
64 |
shortSub1 = "1"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
65 |
data2 = "00001001010100a10110101010010101110101001110110101010010101010010000010111010101010101010a100010010101110111010101101010100010010a100a0010101111111000010101010010101000010101010010101010101110a10010101010101010101010101010"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
66 |
shortSub2 = "a"; |
54043
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
67 |
searchChar = 's'; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
68 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
69 |
string16Short = "scar\u01fe1"; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
70 |
string16Medium = "capaapapapasdkajdlkajskldjaslkjdlkasjdsalksca1r\u01fescar"; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
71 |
string16Long = "2937489745890797905764956790452976742965790437698498409583479067ngdcapaapapapasdkajdlkajskldjaslkjdlkasjdsalkja1sscar\u01fescar"; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
72 |
searchChar16 = 0x1fe; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
73 |
searchString16 = "\u01fe"; |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
74 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
75 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
76 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
77 |
/** IndexOf Micros Chars */ |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
78 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
79 |
public int searchCharLongSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
80 |
return dataStringBig.indexOf(searchChar); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
81 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
82 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
83 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
84 |
public int searchCharMediumSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
85 |
return searchStringBig.indexOf(searchChar); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
86 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
87 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
88 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
89 |
public int searchCharShortSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
90 |
return searchString.indexOf(searchChar); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
91 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
92 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
93 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
94 |
public int searchChar16LongSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
95 |
return string16Long.indexOf(searchChar16); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
96 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
97 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
98 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
99 |
public int searchChar16MediumSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
100 |
return string16Medium.indexOf(searchChar16); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
101 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
102 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
103 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
104 |
public int searchChar16ShortSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
105 |
return string16Short.indexOf(searchChar16); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
106 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
107 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
108 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
109 |
public int searchChar16LongWithOffsetSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
110 |
return string16Long.indexOf(searchChar16, 3); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
111 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
112 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
113 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
114 |
public int searchChar16MediumWithOffsetSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
115 |
return string16Medium.indexOf(searchChar16, 3); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
116 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
117 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
118 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
119 |
public int searchChar16ShortWithOffsetSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
120 |
return string16Short.indexOf(searchChar16, 2); |
52595
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
121 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
122 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
123 |
/** IndexOf Micros Strings */ |
54043
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
124 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
125 |
public int searchString16LongLatinSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
126 |
return string16Long.indexOf(shortSub1); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
127 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
128 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
129 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
130 |
public int searchString16MediumLatinSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
131 |
return string16Medium.indexOf(shortSub1); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
132 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
133 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
134 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
135 |
public int searchString16ShortLatinSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
136 |
return string16Long.indexOf(shortSub2); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
137 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
138 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
139 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
140 |
public int searchString16LongWithOffsetLatinSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
141 |
return string16Long.indexOf(shortSub1, 3); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
142 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
143 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
144 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
145 |
public int searchString16MediumWithOffsetLatinSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
146 |
return string16Medium.indexOf(shortSub1, 3); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
147 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
148 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
149 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
150 |
public int searchString16ShortWithOffsetLatinSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
151 |
return string16Short.indexOf(shortSub2, 1); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
152 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
153 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
154 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
155 |
public int searchString16LongWithOffsetSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
156 |
return string16Long.indexOf(searchString16, 3); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
157 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
158 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
159 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
160 |
public int searchString16MediumWithOffsetSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
161 |
return string16Medium.indexOf(searchString16, 3); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
162 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
163 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
164 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
165 |
public int searchString16ShortWithOffsetSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
166 |
return string16Short.indexOf(searchString16, 2); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
167 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
168 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
169 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
170 |
public int searchString16LongSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
171 |
return string16Long.indexOf(searchString16); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
172 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
173 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
174 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
175 |
public int searchString16MediumSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
176 |
return string16Medium.indexOf(searchString16); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
177 |
} |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
178 |
|
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
179 |
@Benchmark |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
180 |
public int searchString16ShortSuccess() { |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
181 |
return string16Short.indexOf(searchString16); |
0324b3756aa2
8220368: Update String.indexOf to test all the C2 intrinsics
ecaspole
parents:
52595
diff
changeset
|
182 |
} |
52595
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
183 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
184 |
/** |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
185 |
* Benchmarks String.indexOf with a rather small String to search and a rather small String to search for. The |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
186 |
* searched string contains the string that is searched for. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
187 |
*/ |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
188 |
@Benchmark |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
189 |
public int success() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
190 |
return dataString.indexOf(searchString, 2); |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
191 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
192 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
193 |
/** |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
194 |
* Benchmarks String.indexOf with a rather big String to search and a rather big String to search for. The searched |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
195 |
* string contains the string that is searched for. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
196 |
*/ |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
197 |
@Benchmark |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
198 |
public int successBig() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
199 |
return dataStringBig.indexOf(searchStringBig, 2); |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
200 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
201 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
202 |
/** |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
203 |
* Benchmarks String.indexOf with a rather big String. Search repeatedly for a matched that is 8 chars and most |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
204 |
* oftenly will require a inner lopp match in String.indexOf with sse42. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
205 |
*/ |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
206 |
@Benchmark |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
207 |
public int advancedWithMediumSub() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
208 |
int index = 0; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
209 |
int dummy = 0; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
210 |
while ((index = data.indexOf(sub, index)) > -1) { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
211 |
index++; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
212 |
dummy += index; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
213 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
214 |
return dummy; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
215 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
216 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
217 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
218 |
/** |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
219 |
* Benchmarks String.indexOf with a rather big String. Search repeatedly for a matched that is 1 chars will find a |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
220 |
* huge amount of matches |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
221 |
*/ |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
222 |
@Benchmark |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
223 |
public int advancedWithShortSub1() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
224 |
int dummy = 0; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
225 |
int index = 0; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
226 |
while ((index = data.indexOf(shortSub1, index)) > -1) { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
227 |
index++; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
228 |
dummy += index; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
229 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
230 |
return dummy; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
231 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
232 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
233 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
234 |
/** |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
235 |
* Benchmarks String.indexOf with a rather big String. Search repeatedly for a matched that is 1 chars but only with |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
236 |
* a few matches. |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
237 |
*/ |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
238 |
@Benchmark |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
239 |
public int advancedWithShortSub2() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
240 |
int dummy = 0; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
241 |
int index = 0; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
242 |
while ((index = data2.indexOf(shortSub2, index)) > -1) { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
243 |
index++; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
244 |
dummy += index; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
245 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
246 |
return dummy; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
247 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
248 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
249 |
@Benchmark |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
250 |
public void constantPattern() { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
251 |
String tmp = "simple-hash:SHA-1/UTF-8"; |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
252 |
if (!tmp.contains("SHA-1")) { |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
253 |
throw new RuntimeException("indexOf failed"); |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
254 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
255 |
} |
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
256 |
|
16609197022c
8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff
changeset
|
257 |
} |