8220368: Update String.indexOf to test all the C2 intrinsics
authorecaspole
Fri, 08 Mar 2019 17:45:40 -0500
changeset 54043 0324b3756aa2
parent 54042 6dd6f988b4e4
child 54044 d9853137aa28
child 57250 b38f280d2114
8220368: Update String.indexOf to test all the C2 intrinsics Summary: Add new micros for Latin1 and UTF-16 Reviewed-by: kvn, redestad
test/micro/org/openjdk/bench/java/lang/StringIndexOf.java
--- a/test/micro/org/openjdk/bench/java/lang/StringIndexOf.java	Fri Mar 08 23:02:06 2019 +0100
+++ b/test/micro/org/openjdk/bench/java/lang/StringIndexOf.java	Fri Mar 08 17:45:40 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,12 @@
     private String shortSub1;
     private String data2;
     private String shortSub2;
+    private String string16Short;
+    private String string16Medium;
+    private String string16Long;
+    private char searchChar;
+    private char searchChar16;
+    private String searchString16;
 
     @Setup
     public void setup() {
@@ -58,9 +64,122 @@
         shortSub1 = "1";
         data2 = "00001001010100a10110101010010101110101001110110101010010101010010000010111010101010101010a100010010101110111010101101010100010010a100a0010101111111000010101010010101000010101010010101010101110a10010101010101010101010101010";
         shortSub2 = "a";
+        searchChar = 's';
+
+        string16Short = "scar\u01fe1";
+        string16Medium = "capaapapapasdkajdlkajskldjaslkjdlkasjdsalksca1r\u01fescar";
+        string16Long = "2937489745890797905764956790452976742965790437698498409583479067ngdcapaapapapasdkajdlkajskldjaslkjdlkasjdsalkja1sscar\u01fescar";
+        searchChar16 = 0x1fe;
+        searchString16 = "\u01fe";
+    }
+
+
+    /** IndexOf Micros Chars */
+    @Benchmark
+    public int searchCharLongSuccess() {
+        return dataStringBig.indexOf(searchChar);
+    }
+
+    @Benchmark
+    public int searchCharMediumSuccess() {
+        return searchStringBig.indexOf(searchChar);
+    }
+
+    @Benchmark
+    public int searchCharShortSuccess() {
+        return searchString.indexOf(searchChar);
+    }
+
+    @Benchmark
+    public int searchChar16LongSuccess() {
+        return string16Long.indexOf(searchChar16);
+    }
+
+    @Benchmark
+    public int searchChar16MediumSuccess() {
+        return string16Medium.indexOf(searchChar16);
+    }
+
+    @Benchmark
+    public int searchChar16ShortSuccess() {
+        return string16Short.indexOf(searchChar16);
+    }
+
+    @Benchmark
+    public int searchChar16LongWithOffsetSuccess() {
+        return string16Long.indexOf(searchChar16, 3);
+    }
+
+    @Benchmark
+    public int searchChar16MediumWithOffsetSuccess() {
+        return string16Medium.indexOf(searchChar16, 3);
+    }
+
+    @Benchmark
+    public int searchChar16ShortWithOffsetSuccess() {
+        return string16Short.indexOf(searchChar16, 2);
     }
 
     /** IndexOf Micros Strings */
+    @Benchmark
+    public int searchString16LongLatinSuccess() {
+        return string16Long.indexOf(shortSub1);
+    }
+
+    @Benchmark
+    public int searchString16MediumLatinSuccess() {
+        return string16Medium.indexOf(shortSub1);
+    }
+
+    @Benchmark
+    public int searchString16ShortLatinSuccess() {
+        return string16Long.indexOf(shortSub2);
+    }
+
+    @Benchmark
+    public int searchString16LongWithOffsetLatinSuccess() {
+        return string16Long.indexOf(shortSub1, 3);
+    }
+
+    @Benchmark
+    public int searchString16MediumWithOffsetLatinSuccess() {
+        return string16Medium.indexOf(shortSub1, 3);
+    }
+
+    @Benchmark
+    public int searchString16ShortWithOffsetLatinSuccess() {
+        return string16Short.indexOf(shortSub2, 1);
+    }
+
+    @Benchmark
+    public int searchString16LongWithOffsetSuccess() {
+        return string16Long.indexOf(searchString16, 3);
+    }
+
+    @Benchmark
+    public int searchString16MediumWithOffsetSuccess() {
+        return string16Medium.indexOf(searchString16, 3);
+    }
+
+    @Benchmark
+    public int searchString16ShortWithOffsetSuccess() {
+        return string16Short.indexOf(searchString16, 2);
+    }
+
+    @Benchmark
+    public int searchString16LongSuccess() {
+        return string16Long.indexOf(searchString16);
+    }
+
+    @Benchmark
+    public int searchString16MediumSuccess() {
+        return string16Medium.indexOf(searchString16);
+    }
+
+    @Benchmark
+    public int searchString16ShortSuccess() {
+        return string16Short.indexOf(searchString16);
+    }
 
     /**
      * Benchmarks String.indexOf with a rather small String to search and a rather small String to search for. The