< prev index next >
test/micro/org/openjdk/bench/java/lang/StringBuilders.java
Print this page
*** 1,7 ****
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2014 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 40,51 ****
private String[] strings;
private String[] str3p4p2;
private String[] str16p8p7;
private String[] str3p9p8;
private String[] str22p40p31;
- private StringBuilder sbLatin1;
- private StringBuilder sbUtf16;
@Setup
public void setup() {
strings = new String[]{"As", "your", "attorney,", "I",
"advise", "you", "to", "drive", "at", "top", "speed", "it'll",
--- 40,49 ----
*** 53,64 ****
"there", "before", "you", "turn", "into", "a", "wild", "animal."};
str3p4p2 = new String[]{"123", "1234", "12"};
str16p8p7 = new String[]{"1234567890123456", "12345678", "1234567"};
str3p9p8 = new String[]{"123", "123456789", "12345678"};
str22p40p31 = new String[]{"1234567890123456789012", "1234567890123456789012345678901234567890", "1234567890123456789012345678901"};
- sbLatin1 = new StringBuilder("Latin1 string");
- sbUtf16 = new StringBuilder("UTF-\uFF11\uFF16 string");
}
/** StringBuilder wins over StringMaker. */
@Benchmark
public String concat3p4p2() throws Exception {
--- 51,60 ----
*** 258,283 ****
result.append("stringelinglinglinglong");
result.append('p');
result.append("stringelinglinglinglong");
return result.toString();
}
-
- @Benchmark
- public StringBuilder fromLatin1String() {
- return new StringBuilder("Latin1 string");
- }
-
- @Benchmark
- public StringBuilder fromUtf16String() {
- return new StringBuilder("UTF-\uFF11\uFF16 string");
- }
-
- @Benchmark
- public StringBuilder fromLatin1StringBuilder() {
- return new StringBuilder(sbLatin1);
- }
-
- @Benchmark
- public StringBuilder fromUtf16StringBuilder() {
- return new StringBuilder(sbUtf16);
- }
}
--- 254,259 ----
< prev index next >