< prev index next >

test/micro/org/openjdk/bench/java/lang/StringConcat.java

Print this page
rev 54622 : 8222852: Reduce String concat combinator tree shapes by folding constants into prependers
Reviewed-by: shade, plevart
Contributed-by: claes.redestad@oracle.com, peter.levart@gmail.com


  61     public String concatConstString() {
  62         return "string" + stringValue;
  63     }
  64 
  65     @Benchmark
  66     public String concatMethodConstString() {
  67         return "string".concat(stringValue);
  68     }
  69 
  70     @Benchmark
  71     public String concatConstIntConstInt() {
  72         return "string" + intValue + "string" + intValue;
  73     }
  74 
  75     @Benchmark
  76     public String concatConstStringConstInt() {
  77         return "string" + stringValue + "string" + intValue;
  78     }
  79 
  80     @Benchmark










  81     public String concatConst4String() {
  82         return "string" + stringValue + stringValue + stringValue + stringValue;
  83     }
  84 
  85     @Benchmark





  86     public String concatConst2String() {
  87         return "string" + stringValue + stringValue;
  88     }
  89 
  90     @Benchmark
  91     public String concatConstBoolByte() {
  92         return "string" + boolValue + byteValue;
  93     }
  94 
  95     @Benchmark
  96     public String concatConst6String() {
  97         return "string" + stringValue + stringValue + stringValue + stringValue + stringValue + stringValue;





  98     }
  99 
 100     @Benchmark
 101     public String concatConst6Object() {
 102         return "string" + objectValue + objectValue + objectValue + objectValue + objectValue + objectValue;
 103     }
 104 
 105 }


  61     public String concatConstString() {
  62         return "string" + stringValue;
  63     }
  64 
  65     @Benchmark
  66     public String concatMethodConstString() {
  67         return "string".concat(stringValue);
  68     }
  69 
  70     @Benchmark
  71     public String concatConstIntConstInt() {
  72         return "string" + intValue + "string" + intValue;
  73     }
  74 
  75     @Benchmark
  76     public String concatConstStringConstInt() {
  77         return "string" + stringValue + "string" + intValue;
  78     }
  79 
  80     @Benchmark
  81     public String concatMix4String() {
  82         // Investigate "profile pollution" between shared LFs that might eliminate some JIT optimizations
  83         String s1 = "string" + stringValue + stringValue + stringValue + stringValue;
  84         String s2 = "string" + stringValue + "string" + stringValue + stringValue + stringValue;
  85         String s3 = stringValue + stringValue + "string" + stringValue + "string" + stringValue + "string";
  86         String s4 = "string" + stringValue + "string" + stringValue + "string" + stringValue + "string" + stringValue + "string";
  87         return s1 + s2 + s3 + s4;
  88     }
  89 
  90     @Benchmark
  91     public String concatConst4String() {
  92         return "string" + stringValue + stringValue + stringValue + stringValue;
  93     }
  94 
  95     @Benchmark
  96     public String concat4String() {
  97         return stringValue + stringValue + stringValue + stringValue;
  98     }
  99 
 100     @Benchmark
 101     public String concatConst2String() {
 102         return "string" + stringValue + stringValue;
 103     }
 104 
 105     @Benchmark
 106     public String concatConstBoolByte() {
 107         return "string" + boolValue + byteValue;
 108     }
 109 
 110     @Benchmark
 111     public String concatConst6String() {
 112         return "string" + stringValue + stringValue + stringValue + stringValue + stringValue + stringValue;
 113     }
 114 
 115     @Benchmark
 116     public String concat6String() {
 117         return stringValue + stringValue + stringValue + stringValue + stringValue + stringValue;
 118     }
 119 
 120     @Benchmark
 121     public String concatConst6Object() {
 122         return "string" + objectValue + objectValue + objectValue + objectValue + objectValue + objectValue;
 123     }
 124 
 125 }
< prev index next >