author | igerasim |
Fri, 16 Aug 2019 11:35:17 -0700 | |
changeset 57783 | a0257f1458aa |
permissions | -rw-r--r-- |
57783
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
1 |
/* |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
4 |
* |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
8 |
* |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
13 |
* accompanied this code). |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
14 |
* |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
18 |
* |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
21 |
* questions. |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
22 |
*/ |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
23 |
|
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
24 |
package org.openjdk.bench.java.lang; |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
25 |
|
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
26 |
import org.openjdk.jmh.annotations.*; |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
27 |
import java.util.concurrent.TimeUnit; |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
28 |
|
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
29 |
@BenchmarkMode(Mode.AverageTime) |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
30 |
@OutputTimeUnit(TimeUnit.NANOSECONDS) |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
31 |
@State(Scope.Benchmark) |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
32 |
public class StringSubstring { |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
33 |
|
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
34 |
public String s = new String("An arbitrary string that happened to be of length 52"); |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
35 |
|
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
36 |
@Benchmark |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
37 |
public String from26toEnd0() { |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
38 |
return s.substring(26); |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
39 |
} |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
40 |
|
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
41 |
@Benchmark |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
42 |
public String from26toEnd1() { |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
43 |
return s.substring(26, s.length()); |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
44 |
} |
a0257f1458aa
8221307: String.substring() OOB exception on start index reports improper information
igerasim
parents:
diff
changeset
|
45 |
} |