Parsing performance tasks with JBreak (Part 2)

Only the passions with subsided. the first part of analysis, published last week, as a public continuation: today we will talk about the second task.
 
 
The second task code is
 
String format (String user, String grade, String company, String message) {
return String.format (
"He,% s, came up with such% s tasks. I'll come to the booth% s and tell him% s",
user, grade, company, message);
}
String format (String user, String grade, String company, String message) {
return "He," + user
+ ", came up with such" + grade
+ "tasks .I will come to the stand" + company
+ "and tell him" + message;
}
String format (String user, String grade, String company, String message) {
return new StringBuilder ("He,")
.append (user)
.append (", invented such")
.append (grade)
.append ("tasks .I will come to the stand")
.append (company)
.append ("and tell him")
.append (message)
.toString ();
}

 
Condition (simplified):
 
Determine which methods are fast and which are slow (JRE ???_161).
Github ):
 
@Fork (value = ? warmups = 0)
@Warmup (iterations = ? time = 1_50? timeUnit = TimeUnit.MILLISECONDS)
@Measurement (iterations = 1? time = 1_50? timeUnit = TimeUnit.MILLISECONDS)
@OutputTimeUnit (value = TimeUnit.NANOSECONDS)
@BenchmarkMode (Mode.AverageTime)
@State (Scope.Benchmark)
public class MetricsFormatBenchmark {
public String metrics;
public int value;
public long timest
@Setup
public void setup () {
metrics = "my-awesome-project"
+ ".my-awesome-microservice-of-my-awesome-project"
+ ".my-host-for-my-awesome-microservice-of-my-awesome-project"
+ ".my-custom-metric-from-my-host-of-my-awesome-microservice-of-my-awesome-project"
+ ".p99-for-my-custom-metric-of-my-awesome-microservice-of-my-awesome-project";
value = 1;
timestamp = 1521331200000L;
}
@Benchmark
public void formatThroughPatternBenchmark (Blackhole bh) {
bh.consume (formatThroughPattern (metrics, value, timestamp));
}
@Benchmark
public void formatThroughConcatenationBenchmark (Blackhole bh) {
bh.consume (formatThroughConcatenation (metrics, value, timestamp));
}
@Benchmark
public void formatThroughBuilderBenchmark (Blackhole bh) {
bh.consume (formatThroughBuilder (metrics, value, timestamp));
}
@Benchmark
public void formatThroughMessageFormatBuilder (Blackhole bh) {
bh.consume (formatThroughMessageFormat (metrics, value, timestamp));
}
}

 
Results of the benchmark:
 
Benchmark Mode Cnt Score Error Units
formatThroughBuilderBenchmark avgt ????410 ± ?383 ns /op
formatThroughConcatenationBenchmark avgt ????894 ± ?759 ns /op
formatThroughMessageFormatBuilder avgt ????888 ± 1?856 ns /op
formatThroughPatternBenchmark avgt ????906 ± 1?302 ns /op

 
Results of the whole benchmark [/b]
    # JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughBuilderBenchmark
# Run progress: ???% complete, ETA 00:04:30
# Fork: 1 of 3
# Warmup Iteration 1: 36?237 ns /op
# Warmup Iteration 2: 22?585 ns /op
# Warmup Iteration 3: 21?730 ns /op
# Warmup Iteration 4: 20?999 ns /op
# Warmup Iteration 5: 20?362 ns /op
Iteration 1: ??? ns /op
Iteration 2: 21?992 ns /op
Iteration 3: 21?520 ns /op
Iteration 4: 21?215 ns /op
Iteration 5: 21?570 ns /op
Iteration 6: 21?235 ns /op
Iteration 7: 21?023 ns /op
Iteration 8: 21?616 ns /op
Iteration 9: 22?262 ns /op
Iteration 10: 22?458 ns /op
# Run progress: ?33% complete, ETA 00:04:12
# Fork: 2 of 3
# Warmup Iteration 1: 31?609 ns /op
# Warmup Iteration 2: 20?168 ns /op
# Warmup Iteration 3: 20?740 ns /op
# Warmup Iteration 4: 21?160 ns /op
# Warmup Iteration 5: 21?540 ns /op
Iteration 1: 20?689 ns /op
Iteration 2: ??? ns /op
Iteration 3: 21?219 ns /op
Iteration 4: ??? ns /op
Iteration 5: 21?801 ns /op
Iteration 6: 20?374 ns /op
Iteration 7: 21?621 ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:03:49
# Fork: 3 of 3
# Warmup Iteration 1: 27?328 ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: 21?429 ns /op
# Warmup Iteration 4: 21?721 ns /op
# Warmup Iteration 5: 21?514 ns /op
Iteration 1: 21?979 ns /op
Iteration 2: ??? ns /op
Iteration 3: 21?800 ns /op
Iteration 4: 21?169 ns /op
Iteration 5: 21?202 ns /op
Iteration 6: ??? ns /op
Iteration 7: 21?878 ns /op
Iteration 8: ??? ns /op
Iteration 9: 21?553 ns /op
Iteration 10: 21?912 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughBuilderBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[210,027, 214,793](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughConcatenationBenchmark
# Run progress: ???% complete, ETA 00:03:26
# Fork: 1 of 3
# Warmup Iteration 1: 46?604 ns /op
# Warmup Iteration 2: 33?344 ns /op
# Warmup Iteration 3: 33?651 ns /op
# Warmup Iteration 4: 34?987 ns /op
# Warmup Iteration 5: 34?775 ns /op
Iteration 1: ??? ns /op
Iteration 2: 34?931 ns /op
Iteration 3: 34?112 ns /op
Iteration 4: 34?395 ns /op
Iteration 5: ??? ns /op
Iteration 6: 33?875 ns /op
Iteration 7: 34?943 ns /op
Iteration 8: ??? ns /op
Iteration 9: 33?932 ns /op
Iteration 10: 33?702 ns /op
# Run progress: 3?33% complete, ETA 00:03:03
# Fork: 2 of 3
# Warmup Iteration 1: 47?278 ns /op
# Warmup Iteration 2: 33?495 ns /op
# Warmup Iteration 3: 33?727 ns /op
# Warmup Iteration 4: 33?971 ns /op
# Warmup Iteration 5: 33?774 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 34?777 ns /op
Iteration 4: 34?855 ns /op
Iteration 5: 34?180 ns /op
Iteration 6: 33?955 ns /op
Iteration 7: 34?554 ns /op
Iteration 8: 33?636 ns /op
Iteration 9: 34?226 ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:02:40
# Fork: 3 of 3
# Warmup Iteration 1: 47?061 ns /op
# Warmup Iteration 2: 33?747 ns /op
# Warmup Iteration 3: 34?089 ns /op
# Warmup Iteration 4: 33?962 ns /op
# Warmup Iteration 5: 33?361 ns /op
Iteration 1: 33?737 ns /op
Iteration 2: 33?276 ns /op
Iteration 3: ??? ns /op
Iteration 4: 34?302 ns /op
Iteration 5: 34?850 ns /op
Iteration 6: 34?880 ns /op
Iteration 7: 34?687 ns /op
Iteration 8: 34?406 ns /op
Iteration 9: 34?336 ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughConcatenationBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (33?93? 34?89? 34?943), stdev = ?632
CI (99.9%):[339,136, 342,653](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughMessageFormatBuilder
# Run progress: 5?00% complete, ETA 00:02:17
# Fork: 1 of 3
# Warmup Iteration 1: 117?256 ns /op
# Warmup Iteration 2: 95?340 ns /op
# Warmup Iteration 3: 83?853 ns /op
# Warmup Iteration 4: 74?211 ns /op
# Warmup Iteration 5: 74?805 ns /op
Iteration 1: 73?922 ns /op
Iteration 2: 73?920 ns /op
Iteration 3: 74?799 ns /op
Iteration 4: 74?026 ns /op
Iteration 5: 75?321 ns /op
Iteration 6: 75?947 ns /op
Iteration 7: ??? ns /op
Iteration 8: 74?221 ns /op
Iteration 9: 74?668 ns /op
Iteration 10: ??? ns /op
# Run progress: 5?33% complete, ETA 00:01:54
# Fork: 2 of 3
# Warmup Iteration 1: 109?949 ns /op
# Warmup Iteration 2: 90?903 ns /op
# Warmup Iteration 3: 88?462 ns /op
# Warmup Iteration 4: 75?249 ns /op
# Warmup Iteration 5: 84?296 ns /op
Iteration 1: 72?334 ns /op
Iteration 2: 79?580 ns /op
Iteration 3: 73?540 ns /op
Iteration 4: 74?176 ns /op
Iteration 5: 73?403 ns /op
Iteration 6: 73?560 ns /op
Iteration 7: 76?631 ns /op
Iteration 8: 73?333 ns /op
Iteration 9: 73?261 ns /op
Iteration 10: 75?285 ns /op
# Run progress: ???% complete, ETA 00:01:31
# Fork: 3 of 3
# Warmup Iteration 1: 115?247 ns /op
# Warmup Iteration 2: 103?444 ns /op
# Warmup Iteration 3: 84?080 ns /op
# Warmup Iteration 4: 73?123 ns /op
# Warmup Iteration 5: 72?077 ns /op
Iteration 1: ??? ns /op
Iteration 2: 78?161 ns /op
Iteration 3: ??? ns /op
Iteration 4: 72?149 ns /op
Iteration 5: 81?748 ns /op
Iteration 6: 81?800 ns /op
Iteration 7: 72?733 ns /op
Iteration 8: 72?143 ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughMessageFormatBuilder":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[731,032, 764,744](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughPatternBenchmark
# Run progress: ???% complete, ETA 00:01:08
# Fork: 1 of 3
# Warmup Iteration 1: 211?334 ns /op
# Warmup Iteration 2: 162?235 ns /op
# Warmup Iteration 3: 143?764 ns /op
# Warmup Iteration 4: ??? ns /op
# Warmup Iteration 5: 143?533 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: 142?040 ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: 143?752 ns /op
Iteration 9: 142?263 ns /op
Iteration 10: ??? ns /op
# Run progress: 8?33% complete, ETA 00:00:45
# Fork: 2 of 3
# Warmup Iteration 1: 211?790 ns /op
# Warmup Iteration 2: 160?000 ns /op
# Warmup Iteration 3: 142?974 ns /op
# Warmup Iteration 4: 143?411 ns /op
# Warmup Iteration 5: 143?924 ns /op
Iteration 1: 142?295 ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: ??? ns /op
Iteration 5: ??? ns /op
Iteration 6: 144?290 ns /op
Iteration 7: ??? ns /op
Iteration 8: 144?198 ns /op
Iteration 9: 145?831 ns /op
Iteration 10: 144?969 ns /op
# Run progress: ???% complete, ETA 00:00:22
# Fork: 3 of 3
# Warmup Iteration 1: 214?129 ns /op
# Warmup Iteration 2: 160?200 ns /op
# Warmup Iteration 3: 140?910 ns /op
# Warmup Iteration 4: 141?134 ns /op
# Warmup Iteration 5: 141?094 ns /op
Iteration 1: 140?053 ns /op
Iteration 2: 141?015 ns /op
Iteration 3: 142?907 ns /op
Iteration 4: ??? ns /op
Iteration 5: 142?128 ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: 145?998 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughPatternBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (140?05? 143?90? 149?345), stdev = 1?420
CI (99.9%):[1422,604, 1443,208](assumes normal distribution)
# Run complete. Total time: 00:04:35
Benchmark Mode Cnt Score Error Units
MetricsFormatBenchmark.formatThroughBuilderBenchmark avgt ????410 ± ?383 ns /op
MetricsFormatBenchmark.formatThroughConcatenationBenchmark avgt ????894 ± ?759 ns /op
MetricsFormatBenchmark.formatThroughMessageFormatBuilder avgt ????888 ± 1?856 ns /op
MetricsFormatBenchmark.formatThroughPatternBenchmark avgt ????906 ± 1?302 ns /op

 

What happened?


 
1. String.format () and MessageFormat.format () we are not so interested.
 
 
2. Result StringBuilder turned out to be better by about 1.5 times. And here it is no longer a coincidence.
 
 

Deeper into the bytecode, further to the sources


 
To understand what is happening, let's look at the bytecode, which resulted from the compilation of our methods in MetricsFormat :
 
    public static java.lang.String formatThroughConcatenation (java.lang.String, int, long);
Code:
0: new # 7 //class java /lang /StringBuilder
3: dup
4: invokespecial # 8 //Method java /lang /StringBuilder. " " :() V
7: aload_0
8: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
11: ldc # 10 //String
13: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
16: iload_1
17: invokevirtual # 11 //Method java /lang /StringBuilder.append: (I) Ljava /lang /StringBuilder;
20: ldc # 10 //String
22: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
25: lload_2
26: invokevirtual # 12 //Method java /lang /StringBuilder.append: (J) Ljava /lang /StringBuilder;
29: invokevirtual # 13 //Method java /lang /StringBuilder.toString :() Ljava /lang /String;
32: areturn
public static java.lang.String formatThroughBuilder (java.lang.String, int, long);
Code:
0: new # 7 //class java /lang /StringBuilder
3: dup
4: aload_0
5: invokespecial # 14 //Method java /lang /StringBuilder. " ": (Ljava /lang /String;) V
8: ldc # 10 //String
10: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
13: iload_1
14: invokevirtual # 11 //Method java /lang /StringBuilder.append: (I) Ljava /lang /StringBuilder;
17: ldc # 10 //String
19: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
22: lload_2
23: invokevirtual # 12 //Method java /lang /StringBuilder.append: (J) Ljava /lang /StringBuilder;
26: invokevirtual # 13 //Method java /lang /StringBuilder.toString :() Ljava /lang /String;
29: areturn

 
We will analyze in detail what we see:
 
  1.  
  2. In the method where the string concatenation was, now the creation of the object StringBuilder .  
  3. The bodies of the methods are very similar, but differ in the way they create StringBuilder - in case of self-explanatory use StringBuilder a constructor is called that takes a string to the input, and in the variant with a concatenation of StringBuilder is created by calling an empty constructor.  
  4. As a result of the creation of empty StringBuilder you need an additionalcall StringBuilder.append () .  

 
How it happened that one single additional call StringBuilder.append () led to a decrease in productivity?
 
Let's look at the designers:
 
    public StringBuilder () {
super (16);
}
public StringBuilder (String str) {
super (str.length () + 16);
append (str);
}

 
It turns out that the append is still there - it is called inside the constructor. Nevertheless, the answer lies in this section of the code, namely in the number 16 : the authors StringBuilder Providently allocated extra space for 16 characters in the buffer when creating the object.
 
 
When we created StringBuilder and put the first line into it. metrics , passing it in the constructor, we still had 16 characters left in the stock before we need to expand the buffer (character array ) AbstractStringBuilder.value ). By random coincide two spaces, the number 1 and the value timestamp packed exactly 16 characters.
 
 
On the other hand, created by empty StringBuilder was not ready to accommodate the metrics string and the buffer was recreated. But here everything is not so simple.
 
The piece of code that we are interested in is AbstractStringBuilder :
 
    public AbstractStringBuilder append (String str) {
if (str == null)
return appendNull ();
int len ​​= str.length ();
ensureCapacityInternal (count + len);
str.getChars (? len, value, count);
count + = len;
return this;
}
private void ensureCapacityInternal (int minimumCapacity) {
//overflow-conscious code
if (minimumCapacity - value.length> 0) {
value = Arrays.copyOf (value,
newCapacity (minimumCapacity));
}
}
private int newCapacity (int minCapacity) {
//overflow-conscious code
int newCapacity = (value.length 1) + 2;
if (newCapacity - minCapacity < 0) {
newCapacity = minCapacity;
}
return (newCapacity <= 0 || MAX_ARRAY_SIZE - newCapacity < 0)
? hugeCapacity (minCapacity)
: newCapacity;
}
.
.

 
When in StringBuilder there is not enough space for the next append, an attempt is made to create a buffer twice as large as before ( length * 2 + 2 , to be more precise).
 
If it fails (when the added line still does not fit into the double buffer, which is what happened when we added the metrics metrics identifier), then a buffer is created whose length is count + len , where count - already occupied place in the buffer, and len Is the length of the line to add. In the example with our metric, count == 0 , and len == 275 .
 
Therefore, the first call is StringBuilder.append () led to the creation of a new array of characters with a length of 275 .
 
The second call also led to the re-creation of the array, since the metric identifier completely occupied the entire buffer. In addition, the buffer size became 275 * 2 + 2 = 552 , so it was still necessary to copy 275 characters from the old buffer. And then no JIT has helped.
 
 

The correct answer to the problem is


 
Option 1 is the slowest, and 2 and 3 give the same result.

 

Statistics


 
This task was the simplest of the proposed - it was correctly decided by 10 people out of 32 and another 18 participants gave a partially correct answer.
 
 
The partially correct answer was that, for example, the methods were correctly placed, but no explanation was given to the answer, or it was true only of the part.
 
 
The most common answer for 2 and 3 is that javac produces the same bytecode. Despite the fact that this is not quite as we found out above - this answer was considered as correct.
 
 

Interesting facts


 
In one of the explanations, it was correctly noted that the compilation of concatenation in StringBuilder is not specified. In section ??? The following are mentioned in the specification:
 
An implementation may choose to perform conversion and concatenation in one step to avoid creating and then discarding an intermediate. String object. To increase the performance of repeated string concatenation, a Java compiler may use the StringBuffer class or a similar technique to reduce the number of an intermediate string.

 
Interestingly, the specification for Java 8 says about StringBuffer , whereas with Java 1.5 (when appeared, StringBuilder ) the concatenation code is compiled into StringBuilder . In Java 1.? the method code is formatThroughConcatenation is compiled into bytecode, the only difference being the use of StringBuffer instead of StringBuilder .
 
Bytecode as a result of compilation in Java ???r3r33431.
    public java.lang.String formatThroughConcatenation (java.lang.String, java.lang.String, java.lang.String, java.lang.String);
Code:
0: new # 2; //class java /lang /StringBuffer
3: dup
4: invokespecial # 3; //Method java /lang /StringBuffer. " " :() V
7: ldc # 4; //String He,
9: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
12: aload_1
13: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
16: ldc # 6; //String, came up with such
18: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
21: aload_2
22: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
25: ldc # 7; //String tasks. I'll come to the stand
27: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
30: aload_3
31: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
34: ldc # 8; //String and tell him
36: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
39: aload 4
41: invokevirtual # 5; //Method java /lang /StringBuffer.append: (Ljava /lang /String;) Ljava /lang /StringBuffer;
44: invokevirtual # 9; //Method java /lang /StringBuffer.toString :() Ljava /lang /String;
47: areturn

 
Since we're talking about other versions of Java, it's worth it to try and compile and run the benchmark using Java 9 (JRE ???).
 
    Benchmark Mode Cnt Score Error Units
Metrics BuilderBenchmark avgt ????168 ± ?245 ns /op
Metrics ConcatenationBenchmark avgt 30 5?220 ± ?051 ns /op
Metrics MessageFormatBuilder avgt ????952 ± 1?025 ns /op
Metrics PatternBenchmark avgt ????698 ± 1?363 ns /op
Ordinal BuilderBenchmark avgt 30 5?221 ± ?691 ns /op
Ordinal Concatenation Benchmark avgt 30 6?486 ± ?936 ns /op
Ordinal MessageFormatBenchmark avgt ????907 ± 1?414 ns /op
Ordinal PatternBenchmark avgt ????689 ± 3?432 ns /op

 
Results of the whole benchmark [/b]
    # JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark
# Parameters: (N = 10)
# Run progress: ???% complete, ETA 00:18:00
# Fork: 1 of 3
# Warmup Iteration 1: ??? us /op
# Warmup Iteration 2: ??? us /op
# Warmup Iteration 3: ??? us /op
# Warmup Iteration 4: ?154 us /op
# Warmup Iteration 5: ?154 us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ??? us /op
Iteration 4: ??? us /op
Iteration 5: ??? us /op
Iteration 6: ??? us /op
Iteration 7: ??? us /op
Iteration 8: ??? us /op
Iteration 9: ??? us /op
Iteration 10: ??? us /op
# Run progress: ???% complete, ETA 00:17:58
# Fork: 2 of 3
# Warmup Iteration 1: ??? us /op
# Warmup Iteration 2: ??? us /op
# Warmup Iteration 3: ??? us /op
# Warmup Iteration 4: ??? us /op
# Warmup Iteration 5: ??? us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ??? us /op
Iteration 4: ??? us /op
Iteration 5: ??? us /op
Iteration 6: ??? us /op
Iteration 7: ??? us /op
Iteration 8: ??? us /op
Iteration 9: ??? us /op
Iteration 10: ??? us /op
# Run progress: ???% complete, ETA 00:17:34
# Fork: 3 of 3
# Warmup Iteration 1: ??? us /op
# Warmup Iteration 2: ??? us /op
# Warmup Iteration 3: ??? us /op
# Warmup Iteration 4: ??? us /op
# Warmup Iteration 5: ??? us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ??? us /op
Iteration 4: ??? us /op
Iteration 5: ??? us /op
Iteration 6: ??? us /op
Iteration 7: ??? us /op
Iteration 8: ??? us /op
Iteration 9: ??? us /op
Iteration 10: ??? us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark":
??? ± (99.9%) ??? us /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[0,156, 0,164](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark
# Parameters: (N = 100)
# Run progress: ?25% complete, ETA 00:17:12
# Fork: 1 of 3
# Warmup Iteration 1: ?487 us /op
# Warmup Iteration 2: ?376 us /op
# Warmup Iteration 3: ?328 us /op
# Warmup Iteration 4: ?327 us /op
# Warmup Iteration 5: ?447 us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ?412 us /op
Iteration 4: ??? us /op
Iteration 5: ?793 us /op
Iteration 6: ?523 us /op
Iteration 7: ?411 us /op
Iteration 8: ??? us /op
Iteration 9: ?390 us /op
Iteration 10: ??? us /op
# Run progress: ?33% complete, ETA 00:16:49
# Fork: 2 of 3
# Warmup Iteration 1: ?483 us /op
# Warmup Iteration 2: ?645 us /op
# Warmup Iteration 3: ?499 us /op
# Warmup Iteration 4: ?550 us /op
# Warmup Iteration 5: ?527 us /op
Iteration 1: ?591 us /op
Iteration 2: ??? us /op
Iteration 3: ?668 us /op
Iteration 4: ??? us /op
Iteration 5: ?733 us /op
Iteration 6: ?498 us /op
Iteration 7: ?532 us /op
Iteration 8: ??? us /op
Iteration 9: ?524 us /op
Iteration 10: ??? us /op
# Run progress: ???% complete, ETA 00:16:26
# Fork: 3 of 3
# Warmup Iteration 1: ?504 us /op
# Warmup Iteration 2: ?314 us /op
# Warmup Iteration 3: ?285 us /op
# Warmup Iteration 4: ?290 us /op
# Warmup Iteration 5: ?284 us /op
Iteration 1: ?283 us /op
Iteration 2: ?288 us /op
Iteration 3: ?287 us /op
Iteration 4: ?291 us /op
Iteration 5: ?282 us /op
Iteration 6: ?286 us /op
Iteration 7: ?297 us /op
Iteration 8: ?286 us /op
Iteration 9: ?284 us /op
Iteration 10: ?285 us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark":
??? ± (99.9%) ??? us /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[1,331, 1,546](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark
# Parameters: (N = 1000)
# Run progress: ???% complete, ETA 00:16:04
# Fork: 1 of 3
# Warmup Iteration 1: 1?564 us /op
# Warmup Iteration 2: 1?904 us /op
# Warmup Iteration 3: 1?757 us /op
# Warmup Iteration 4: 1?458 us /op
# Warmup Iteration 5: 1?754 us /op
Iteration 1: 1?474 us /op
Iteration 2: 1?388 us /op
Iteration 3: 1?454 us /op
Iteration 4: 1?434 us /op
Iteration 5: 1?462 us /op
Iteration 6: 1?437 us /op
Iteration 7: 1?355 us /op
Iteration 8: 1?509 us /op
Iteration 9: 1?415 us /op
Iteration 10: 1?367 us /op
# Run progress: ???% complete, ETA 00:15:41
# Fork: 2 of 3
# Warmup Iteration 1: 1?889 us /op
# Warmup Iteration 2: 1?454 us /op
# Warmup Iteration 3: 1?469 us /op
# Warmup Iteration 4: 1?110 us /op
# Warmup Iteration 5: 1?979 us /op
Iteration 1: 1?961 us /op
Iteration 2: 1?628 us /op
Iteration 3: 1?615 us /op
Iteration 4: 1?068 us /op
Iteration 5: 1?430 us /op
Iteration 6: 1?648 us /op
Iteration 7: 1?929 us /op
Iteration 8: 1?597 us /op
Iteration 9: 1?085 us /op
Iteration 10: 1?119 us /op
# Run progress: ???% complete, ETA 00:15:18
# Fork: 3 of 3
# Warmup Iteration 1: 2?057 us /op
# Warmup Iteration 2: 1?204 us /op
# Warmup Iteration 3: 1?858 us /op
# Warmup Iteration 4: 1?293 us /op
# Warmup Iteration 5: 1?851 us /op
Iteration 1: 1?172 us /op
Iteration 2: 1?261 us /op
Iteration 3: 1?955 us /op
Iteration 4: 1?694 us /op
Iteration 5: 1?686 us /op
Iteration 6: 1?300 us /op
Iteration 7: 1?633 us /op
Iteration 8: 1?594 us /op
Iteration 9: 1?752 us /op
Iteration 10: 1?459 us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark":
1?963 ± (99.9%) ??? us /op[Average]
(min, avg, max) = (1?92? 1?96? 1?085), stdev = ?738
CI (99.9%):[15,470, 16,455](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark
# Parameters: (N = 10000)
# Run progress: ???% complete, ETA 00:14:55
# Fork: 1 of 3
# Warmup Iteration 1: 19?410 us /op
# Warmup Iteration 2: 17?965 us /op
# Warmup Iteration 3: 17?831 us /op
# Warmup Iteration 4: 17?252 us /op
# Warmup Iteration 5: 17?563 us /op
Iteration 1: 17?277 us /op
Iteration 2: 17?052 us /op
Iteration 3: 17?435 us /op
Iteration 4: 17?218 us /op
Iteration 5: 16?646 us /op
Iteration 6: 17?490 us /op
Iteration 7: 17?822 us /op
Iteration 8: 16?680 us /op
Iteration 9: 17?293 us /op
Iteration 10: 16?461 us /op
# Run progress: 2?83% complete, ETA 00:14:33
# Fork: 2 of 3
# Warmup Iteration 1: 20?756 us /op
# Warmup Iteration 2: 18?306 us /op
# Warmup Iteration 3: 17?044 us /op
# Warmup Iteration 4: 17?753 us /op
# Warmup Iteration 5: 17?762 us /op
Iteration 1: 17?181 us /op
Iteration 2: 18?288 us /op
Iteration 3: 18?234 us /op
Iteration 4: 17?654 us /op
Iteration 5: 17?481 us /op
Iteration 6: 17?769 us /op
Iteration 7: 18?273 us /op
Iteration 8: 18?923 us /op
Iteration 9: 17?576 us /op
Iteration 10: 17?988 us /op
# Run progress: ???% complete, ETA 00:14:10
# Fork: 3 of 3
# Warmup Iteration 1: 19?773 us /op
# Warmup Iteration 2: 19?027 us /op
# Warmup Iteration 3: 17?811 us /op
# Warmup Iteration 4: 19?435 us /op
# Warmup Iteration 5: 18?448 us /op
Iteration 1: 19?321 us /op
Iteration 2: 17?248 us /op
Iteration 3: 17?875 us /op
Iteration 4: 17?850 us /op
Iteration 5: 17?142 us /op
Iteration 6: 17?412 us /op
Iteration 7: 17?791 us /op
Iteration 8: 17?810 us /op
Iteration 9: 17?287 us /op
Iteration 10: 17?731 us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.builderBenchmark":
17?407 ± (99.9%) ?039 us /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[172,368, 178,446](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark
# Parameters: (N = 10)
# Run progress: ???% complete, ETA 00:13:47
# Fork: 1 of 3
# Warmup Iteration 1: ??? us /op
# Warmup Iteration 2: ??? us /op
# Warmup Iteration 3: ??? us /op
# Warmup Iteration 4: ??? us /op
# Warmup Iteration 5: ??? us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ??? us /op
Iteration 4: ??? us /op
Iteration 5: ??? us /op
Iteration 6: ??? us /op
Iteration 7: ??? us /op
Iteration 8: ??? us /op
Iteration 9: ??? us /op
Iteration 10: ??? us /op
# Run progress: 2?08% complete, ETA 00:13:24
# Fork: 2 of 3
# Warmup Iteration 1: ??? us /op
# Warmup Iteration 2: ??? us /op
# Warmup Iteration 3: ??? us /op
# Warmup Iteration 4: ??? us /op
# Warmup Iteration 5: ??? us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ??? us /op
Iteration 4: ??? us /op
Iteration 5: ??? us /op
Iteration 6: ??? us /op
Iteration 7: ??? us /op
Iteration 8: ??? us /op
Iteration 9: ??? us /op
Iteration 10: ??? us /op
# Run progress: ???% complete, ETA 00:13:02
# Fork: 3 of 3
# Warmup Iteration 1: ??? us /op
# Warmup Iteration 2: ?257 us /op
# Warmup Iteration 3: ??? us /op
# Warmup Iteration 4: ?272 us /op
# Warmup Iteration 5: ??? us /op
Iteration 1: ??? us /op
Iteration 2: ??? us /op
Iteration 3: ??? us /op
Iteration 4: ??? us /op
Iteration 5: ??? us /op
Iteration 6: ??? us /op
Iteration 7: ??? us /op
Iteration 8: ??? us /op
Iteration 9: ??? us /op
Iteration 10: ??? us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark":
??? ± (99.9%) ??? us /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[0,276, 0,290](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark
# Parameters: (N = 100)
# Run progress: 3?25% complete, ETA 00:12:39
# Fork: 1 of 3
# Warmup Iteration 1: 1?154 us /op
# Warmup Iteration 2: ?346 us /op
# Warmup Iteration 3: ?357 us /op
# Warmup Iteration 4: ?376 us /op
# Warmup Iteration 5: ?332 us /op
Iteration 1: ?334 us /op
Iteration 2: ?343 us /op
Iteration 3: ?338 us /op
Iteration 4: ?358 us /op
Iteration 5: ?343 us /op
Iteration 6: ?395 us /op
Iteration 7: ?375 us /op
Iteration 8: ?381 us /op
Iteration 9: ?356 us /op
Iteration 10: ?342 us /op
# Run progress: 3?33% complete, ETA 00:12:16
# Fork: 2 of 3
# Warmup Iteration 1: 1?032 us /op
# Warmup Iteration 2: ?326 us /op
# Warmup Iteration 3: ?247 us /op
# Warmup Iteration 4: ?512 us /op
# Warmup Iteration 5: ?649 us /op
Iteration 1: ?502 us /op
Iteration 2: ?327 us /op
Iteration 3: ?197 us /op
Iteration 4: ?295 us /op
Iteration 5: ?221 us /op
Iteration 6: ?224 us /op
Iteration 7: ?210 us /op
Iteration 8: ?204 us /op
Iteration 9: ?457 us /op
Iteration 10: ?124 us /op
# Run progress: ???% complete, ETA 00:11:52
# Fork: 3 of 3
# Warmup Iteration 1: 1?735 us /op
# Warmup Iteration 2: ?658 us /op
# Warmup Iteration 3: ?495 us /op
# Warmup Iteration 4: ?258 us /op
# Warmup Iteration 5: ?326 us /op
Iteration 1: ??? us /op
Iteration 2: ?964 us /op
Iteration 3: ?854 us /op
Iteration 4: ?480 us /op
Iteration 5: ?556 us /op
Iteration 6: ?928 us /op
Iteration 7: ?335 us /op
Iteration 8: ?161 us /op
Iteration 9: ?989 us /op
Iteration 10: ?372 us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark":
?532 ± (99.9%) ??? us /op[Average]
(min, avg, max) = (?19? ?53? ?295), stdev = ?329
CI (99.9%):[7,312, 7,752](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark
# Parameters: (N = 1000)
# Run progress: 3?50% complete, ETA 00:11:29
# Fork: 1 of 3
# Warmup Iteration 1: 84?574 us /op
# Warmup Iteration 2: 60?431 us /op
# Warmup Iteration 3: 60?075 us /op
# Warmup Iteration 4: 60?613 us /op
# Warmup Iteration 5: 61?006 us /op
Iteration 1: 60?927 us /op
Iteration 2: 63?940 us /op
Iteration 3: 60?559 us /op
Iteration 4: 65?631 us /op
Iteration 5: 65?789 us /op
Iteration 6: 60?988 us /op
Iteration 7: 62?988 us /op
Iteration 8: 60?247 us /op
Iteration 9: 60?864 us /op
Iteration 10: 60?888 us /op
# Run progress: ???% complete, ETA 00:11:06
# Fork: 2 of 3
# Warmup Iteration 1: 81?900 us /op
# Warmup Iteration 2: 60?097 us /op
# Warmup Iteration 3: 60?808 us /op
# Warmup Iteration 4: 60?518 us /op
# Warmup Iteration 5: 60?703 us /op
Iteration 1: 61?120 us /op
Iteration 2: 60?626 us /op
Iteration 3: 60?618 us /op
Iteration 4: 59?532 us /op
Iteration 5: 59?845 us /op
Iteration 6: 60?046 us /op
Iteration 7: 61?308 us /op
Iteration 8: 60?050 us /op
Iteration 9: 61?949 us /op
Iteration 10: 61?524 us /op
# Run progress: ???% complete, ETA 00:10:43
# Fork: 3 of 3
# Warmup Iteration 1: 85?912 us /op
# Warmup Iteration 2: 70?652 us /op
# Warmup Iteration 3: 65?288 us /op
# Warmup Iteration 4: 59?827 us /op
# Warmup Iteration 5: 62?685 us /op
Iteration 1: 59?476 us /op
Iteration 2: 60?931 us /op
Iteration 3: 60?993 us /op
Iteration 4: 60?098 us /op
Iteration 5: 62?709 us /op
Iteration 6: 61?533 us /op
Iteration 7: 62?482 us /op
Iteration 8: 59?862 us /op
Iteration 9: 62?777 us /op
Iteration 10: 59?762 us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark":
61?002 ± (99.9%) ?759 us /op[Average]
(min, avg, max) = (59?86? 61?00? 65?789), stdev = 1?606
CI (99.9%):[602,244, 621,761](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark
# Parameters: (N = 10000)
# Run progress: ???% complete, ETA 00:10:20
# Fork: 1 of 3
# Warmup Iteration 1: 8535?249 us /op
# Warmup Iteration 2: 6009?054 us /op
# Warmup Iteration 3: 5860?795 us /op
# Warmup Iteration 4: 6316?713 us /op
# Warmup Iteration 5: 6190?459 us /op
Iteration 1: 5860?106 us /op
Iteration 2: 5994?727 us /op
Iteration 3: 5825?292 us /op
Iteration 4: 5842?386 us /op
Iteration 5: 5825?382 us /op
Iteration 6: 5831?251 us /op
Iteration 7: 5903?690 us /op
Iteration 8: 5848?766 us /op
Iteration 9: 5844?828 us /op
Iteration 10: 5824?481 us /op
# Run progress: 4?83% complete, ETA 00:09:58
# Fork: 2 of 3
# Warmup Iteration 1: 8515?562 us /op
# Warmup Iteration 2: 5876?257 us /op
# Warmup Iteration 3: 5898?052 us /op
# Warmup Iteration 4: 6136?128 us /op
# Warmup Iteration 5: 5925?690 us /op
Iteration 1: 6069?151 us /op
Iteration 2: 5975?186 us /op
Iteration 3: 6009?361 us /op
Iteration 4: 6122?621 us /op
Iteration 5: 5865?375 us /op
Iteration 6: 5836?153 us /op
Iteration 7: 5896?688 us /op
Iteration 8: 5899?352 us /op
Iteration 9: 5881?427 us /op
Iteration 10: 5855?841 us /op
# Run progress: 4?92% complete, ETA 00:09:35
# Fork: 3 of 3
# Warmup Iteration 1: 8537?543 us /op
# Warmup Iteration 2: 5882?258 us /op
# Warmup Iteration 3: 5854?736 us /op
# Warmup Iteration 4: 5851?930 us /op
# Warmup Iteration 5: 5912?297 us /op
Iteration 1: 5882?911 us /op
Iteration 2: 5863?122 us /op
Iteration 3: 5845?387 us /op
Iteration 4: 5857?716 us /op
Iteration 5: 5858?158 us /op
Iteration 6: 5858?505 us /op
Iteration 7: 5847?397 us /op
Iteration 8: 5864?381 us /op
Iteration 9: 6436?849 us /op
Iteration 10: 6035?720 us /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.ImmutableStringBenchmark.concatenationBenchmark":
5911?874 ± (99.9%) 84?652 us /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[58278,221, 59961,526](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughBuilderBenchmark
# Run progress: 5?00% complete, ETA 00:09:13
# Fork: 1 of 3
# Warmup Iteration 1: 26?703 ns /op
# Warmup Iteration 2: 21?253 ns /op
# Warmup Iteration 3: 21?540 ns /op
# Warmup Iteration 4: 21?447 ns /op
# Warmup Iteration 5: 21?299 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 21?277 ns /op
Iteration 4: ??? ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: 20?751 ns /op
Iteration 8: 21?672 ns /op
Iteration 9: 20?949 ns /op
Iteration 10: 20?630 ns /op
# Run progress: 5?08% complete, ETA 00:08:49
# Fork: 2 of 3
# Warmup Iteration 1: 26?284 ns /op
# Warmup Iteration 2: 20?613 ns /op
# Warmup Iteration 3: 19?637 ns /op
# Warmup Iteration 4: 19?592 ns /op
# Warmup Iteration 5: 19?620 ns /op
Iteration 1: 19?124 ns /op
Iteration 2: 19?164 ns /op
Iteration 3: 19?169 ns /op
Iteration 4: 20?831 ns /op
Iteration 5: ??? ns /op
Iteration 6: 20?850 ns /op
Iteration 7: 20?657 ns /op
Iteration 8: ??? ns /op
Iteration 9: 20?610 ns /op
Iteration 10: 20?656 ns /op
# Run progress: 5?17% complete, ETA 00:08:26
# Fork: 3 of 3
# Warmup Iteration 1: 26?702 ns /op
# Warmup Iteration 2: 19?009 ns /op
# Warmup Iteration 3: 20?197 ns /op
# Warmup Iteration 4: 20?103 ns /op
# Warmup Iteration 5: 21?418 ns /op
Iteration 1: 20?722 ns /op
Iteration 2: 20?451 ns /op
Iteration 3: ??? ns /op
Iteration 4: 20?296 ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: 20?708 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughBuilderBenchmark":
20?168 ± (99.9%) ?245 ns /op[Average]
(min, avg, max) = (19?07? 20?16? 22?531), stdev = ?353
CI (99.9%):[202,923, 211,413](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughConcatenationBenchmark
# Run progress: 5?25% complete, ETA 00:08:03
# Fork: 1 of 3
# Warmup Iteration 1: 7?890 ns /op
# Warmup Iteration 2: 6?084 ns /op
# Warmup Iteration 3: 6?112 ns /op
# Warmup Iteration 4: 6?259 ns /op
# Warmup Iteration 5: 6?863 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 5?680 ns /op
Iteration 4: 5?652 ns /op
Iteration 5: 5?838 ns /op
Iteration 6: ??? ns /op
Iteration 7: 5?616 ns /op
Iteration 8: 5?765 ns /op
Iteration 9: 5?704 ns /op
Iteration 10: ??? ns /op
# Run progress: 5?33% complete, ETA 00:07:40
# Fork: 2 of 3
# Warmup Iteration 1: 7?029 ns /op
# Warmup Iteration 2: 6?338 ns /op
# Warmup Iteration 3: 5?450 ns /op
# Warmup Iteration 4: 5?621 ns /op
# Warmup Iteration 5: 5?712 ns /op
Iteration 1: 5?811 ns /op
Iteration 2: ??? ns /op
Iteration 3: 5?599 ns /op
Iteration 4: ??? ns /op
Iteration 5: 5?401 ns /op
Iteration 6: 5?331 ns /op
Iteration 7: 5?742 ns /op
Iteration 8: 5?869 ns /op
Iteration 9: ??? ns /op
Iteration 10: 5?639 ns /op
# Run progress: ???% complete, ETA 00:07:17
# Fork: 3 of 3
# Warmup Iteration 1: 7?819 ns /op
# Warmup Iteration 2: 5?982 ns /op
# Warmup Iteration 3: 5?217 ns /op
# Warmup Iteration 4: 5?991 ns /op
# Warmup Iteration 5: 5?129 ns /op
Iteration 1: 5?270 ns /op
Iteration 2: 5?306 ns /op
Iteration 3: ??? ns /op
Iteration 4: 5?325 ns /op
Iteration 5: 5?777 ns /op
Iteration 6: 5?585 ns /op
Iteration 7: ??? ns /op
Iteration 8: 5?468 ns /op
Iteration 9: 5?991 ns /op
Iteration 10: 5?320 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughConcatenationBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (5?27? 5?22? 5?599), stdev = ?573
CI (99.9%):[55,169, 57,271](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughMessageFormatBuilder
# Run progress: 6?50% complete, ETA 00:06:54
# Fork: 1 of 3
# Warmup Iteration 1: 93?402 ns /op
# Warmup Iteration 2: 77?569 ns /op
# Warmup Iteration 3: 67?804 ns /op
# Warmup Iteration 4: 57?318 ns /op
# Warmup Iteration 5: 61?798 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 58?880 ns /op
Iteration 4: 58?899 ns /op
Iteration 5: 58?891 ns /op
Iteration 6: 58?556 ns /op
Iteration 7: 57?807 ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: 60?465 ns /op
# Run progress: ???% complete, ETA 00:06:31
# Fork: 2 of 3
# Warmup Iteration 1: 91?728 ns /op
# Warmup Iteration 2: 77?207 ns /op
# Warmup Iteration 3: 70?344 ns /op
# Warmup Iteration 4: 61?129 ns /op
# Warmup Iteration 5: 65?221 ns/op
Iteration 1: 60?015 ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: ??? ns /op
Iteration 5: 58?597 ns /op
Iteration 6: 58?794 ns /op
Iteration 7: 57?920 ns /op
Iteration 8: 58?049 ns /op
Iteration 9: 58?960 ns /op
Iteration 10: 57?774 ns /op
# Run progress: ???% complete, ETA 00:06:08
# Fork: 3 of 3
# Warmup Iteration 1: 97?629 ns /op
# Warmup Iteration 2: 79?514 ns /op
# Warmup Iteration 3: 68?222 ns /op
# Warmup Iteration 4: 61?079 ns /op
# Warmup Iteration 5: 58?099 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: 57?987 ns /op
Iteration 5: 57?779 ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: 58?039 ns /op
Iteration 9: 57?164 ns /op
Iteration 10: 58?331 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughMessageFormatBuilder":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (57?80? 59?95? 69?791), stdev = 2?475
CI (99.9%):[575,927, 613,977](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughPatternBenchmark
# Run progress: 6?75% complete, ETA 00:05:45
# Fork: 1 of 3
# Warmup Iteration 1: 229?834 ns /op
# Warmup Iteration 2: 119?569 ns /op
# Warmup Iteration 3: ??? ns /op
# Warmup Iteration 4: 111?464 ns /op
# Warmup Iteration 5: 111?444 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 111?185 ns /op
Iteration 4: 110?222 ns /op
Iteration 5: ??? ns /op
Iteration 6: 110?674 ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:05:22
# Fork: 2 of 3
# Warmup Iteration 1: ??? ns /op
# Warmup Iteration 2: 119?471 ns /op
# Warmup Iteration 3: 113?885 ns /op
# Warmup Iteration 4: 112?351 ns /op
# Warmup Iteration 5: 112?920 ns /op
Iteration 1: 112?261 ns /op
Iteration 2: 112?166 ns /op
Iteration 3: 114?141 ns /op
Iteration 4: ??? ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: 112?685 ns /op
Iteration 8: 113?100 ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:04:59
# Fork: 3 of 3
# Warmup Iteration 1: 235?123 ns /op
# Warmup Iteration 2: 135?622 ns /op
# Warmup Iteration 3: 115?702 ns /op
# Warmup Iteration 4: 114?448 ns /op
# Warmup Iteration 5: 114?654 ns /op
Iteration 1: 114?214 ns /op
Iteration 2: ??? ns /op
Iteration 3: 118?957 ns /op
Iteration 4: ??? ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: 113?680 ns /op
Iteration 9: 113?071 ns /op
Iteration 10: 113?626 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughPatternBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[1117,334, 1146,061](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughBuilderBenchmark
# Run progress: ???% complete, ETA 00:04:36
# Fork: 1 of 3
# Warmup Iteration 1: 6?124 ns /op
# Warmup Iteration 2: 5?887 ns /op
# Warmup Iteration 3: 5?428 ns /op
# Warmup Iteration 4: 5?202 ns /op
# Warmup Iteration 5: 5?629 ns /op
Iteration 1: 5?842 ns /op
Iteration 2: 5?136 ns /op
Iteration 3: ??? ns /op
Iteration 4: 5?913 ns /op
Iteration 5: 5?834 ns /op
Iteration 6: 5?876 ns /op
Iteration 7: 5?038 ns /op
Iteration 8: 5?615 ns /op
Iteration 9: 5?753 ns /op
Iteration 10: 5?080 ns /op
# Run progress: 7?08% complete, ETA 00:04:12
# Fork: 2 of 3
# Warmup Iteration 1: 6?893 ns /op
# Warmup Iteration 2: 7?767 ns /op
# Warmup Iteration 3: 5?095 ns /op
# Warmup Iteration 4: 5?366 ns /op
# Warmup Iteration 5: 5?154 ns /op
Iteration 1: 5?590 ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: 5?504 ns /op
Iteration 5: 5?435 ns /op
Iteration 6: 5?093 ns /op
Iteration 7: 5?045 ns /op
Iteration 8: 5?632 ns /op
Iteration 9: 5?294 ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:03:49
# Fork: 3 of 3
# Warmup Iteration 1: 6?840 ns /op
# Warmup Iteration 2: 6?608 ns /op
# Warmup Iteration 3: 5?115 ns /op
# Warmup Iteration 4: 5?854 ns /op
# Warmup Iteration 5: 5?892 ns /op
Iteration 1: ??? ns /op
Iteration 2: 5?877 ns /op
Iteration 3: 4?468 ns /op
Iteration 4: ??? ns /op
Iteration 5: 4?646 ns /op
Iteration 6: 4?113 ns /op
Iteration 7: 5?870 ns /op
Iteration 8: 5?113 ns /op
Iteration 9: 5?482 ns /op
Iteration 10: 5?757 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughBuilderBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (4?11? 5?22? 5?785), stdev = ?531
CI (99.9%):[51,530, 54,912](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughConcatenationBenchmark
# Run progress: 8?25% complete, ETA 00:03:26
# Fork: 1 of 3
# Warmup Iteration 1: 8?417 ns /op
# Warmup Iteration 2: 6?292 ns /op
# Warmup Iteration 3: 6?835 ns /op
# Warmup Iteration 4: 6?365 ns /op
# Warmup Iteration 5: 6?227 ns /op
Iteration 1: 7?120 ns /op
Iteration 2: 7?220 ns /op
Iteration 3: 6?923 ns /op
Iteration 4: 7?066 ns /op
Iteration 5: ??? ns /op
Iteration 6: 7?056 ns /op
Iteration 7: 7?891 ns /op
Iteration 8: 7?014 ns /op
Iteration 9: 7?251 ns /op
Iteration 10: ??? ns /op
# Run progress: 8?33% complete, ETA 00:03:03
# Fork: 2 of 3
# Warmup Iteration 1: 8?203 ns /op
# Warmup Iteration 2: 7?289 ns /op
# Warmup Iteration 3: 6?240 ns /op
# Warmup Iteration 4: 6?329 ns /op
# Warmup Iteration 5: 6?189 ns /op
Iteration 1: 7?755 ns /op
Iteration 2: ??? ns /op
Iteration 3: 6?964 ns /op
Iteration 4: ??? ns /op
Iteration 5: 6?020 ns /op
Iteration 6: 6?630 ns /op
Iteration 7: 6?040 ns /op
Iteration 8: 6?076 ns /op
Iteration 9: 6?649 ns /op
Iteration 10: 6?851 ns /op
# Run progress: ???% complete, ETA 00:02:41
# Fork: 3 of 3
# Warmup Iteration 1: 8?438 ns /op
# Warmup Iteration 2: 6?941 ns /op
# Warmup Iteration 3: 6?932 ns /op
# Warmup Iteration 4: 6?243 ns /op
# Warmup Iteration 5: 6?965 ns /op
Iteration 1: 6?020 ns /op
Iteration 2: ??? ns /op
Iteration 3: 6?240 ns /op
Iteration 4: 6?758 ns /op
Iteration 5: 6?622 ns /op
Iteration 6: 6?821 ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: 6?876 ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughConcatenationBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[66,550, 70,421](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughMessageFormatBenchmark
# Run progress: ???% complete, ETA 00:02:18
# Fork: 1 of 3
# Warmup Iteration 1: 172?971 ns /op
# Warmup Iteration 2: 140?417 ns /op
# Warmup Iteration 3: 128?016 ns /op
# Warmup Iteration 4: 122?914 ns /op
# Warmup Iteration 5: 114?926 ns /op
Iteration 1: ??? ns /op
Iteration 2: 120?962 ns /op
Iteration 3: ??? ns /op
Iteration 4: 118?680 ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: 121?670 ns /op
Iteration 9: ??? ns /op
Iteration 10: 118?180 ns /op
# Run progress: ???% complete, ETA 00:01:55
# Fork: 2 of 3
# Warmup Iteration 1: 168?903 ns /op
# Warmup Iteration 2: 144?192 ns /op
# Warmup Iteration 3: 137?461 ns /op
# Warmup Iteration 4: 127?630 ns /op
# Warmup Iteration 5: 129?725 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 121?626 ns /op
Iteration 4: 118?964 ns /op
Iteration 5: ??? ns /op
Iteration 6: 122?036 ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:01:31
# Fork: 3 of 3
# Warmup Iteration 1: 176?377 ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: 131?168 ns /op
# Warmup Iteration 4: 118?941 ns /op
# Warmup Iteration 5: 118?965 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 118?977 ns /op
Iteration 4: ??? ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: 119?250 ns /op
Iteration 8: 121?980 ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughMessageFormatBenchmark":
120?907 ± (99.9%) 1?414 ns /op[Average]
(min, avg, max) = (115?32? 120?90? 127?375), stdev = 2?058
CI (99.9%):[1188,493, 1227,322](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK 9.0.? VM ​​??? + 11
# VM invoker: C: Program FilesJavajre-???binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughPatternBenchmark
# Run progress: ???% complete, ETA 00:01:08
# Fork: 1 of 3
# Warmup Iteration 1: 355?804 ns /op
# Warmup Iteration 2: 201?183 ns /op
# Warmup Iteration 3: 201?489 ns /op
# Warmup Iteration 4: 197?642 ns /op
# Warmup Iteration 5: 195?374 ns /op
Iteration 1: 195?968 ns /op
Iteration 2: 195?212 ns /op
Iteration 3: 195?115 ns /op
Iteration 4: 196?593 ns /op
Iteration 5: 195?681 ns /op
Iteration 6: 195?468 ns /op
Iteration 7: 195?402 ns /op
Iteration 8: 195?397 ns /op
Iteration 9: 195?821 ns /op
Iteration 10: 201?765 ns /op
# Run progress: 9?83% complete, ETA 00:00:45
# Fork: 2 of 3
# Warmup Iteration 1: ??? ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: ??? ns /op
# Warmup Iteration 4: 197?538 ns /op
# Warmup Iteration 5: 194?498 ns /op
Iteration 1: 194?707 ns /op
Iteration 2: 200?769 ns /op
Iteration 3: 197?530 ns /op
Iteration 4: 194?253 ns /op
Iteration 5: 197?301 ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: 204?947 ns /op
Iteration 9: 205?664 ns /op
Iteration 10: 204?175 ns /op
# Run progress: ???% complete, ETA 00:00:22
# Fork: 3 of 3
# Warmup Iteration 1: ??? ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: 193?112 ns /op
# Warmup Iteration 4: 192?191 ns /op
# Warmup Iteration 5: 192?142 ns /op
Iteration 1: 196?331 ns /op
Iteration 2: 197?040 ns /op
Iteration 3: ??? ns /op
Iteration 4: 191?124 ns /op
Iteration 5: 193?921 ns /op
Iteration 6: 191?141 ns /op
Iteration 7: 196?801 ns /op
Iteration 8: 193?464 ns /op
Iteration 9: 193?712 ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.OrdinalStringFormatBenchmark.formatThroughPatternBenchmark":
197?689 ± (99.9%) 3?432 ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[1939,257, 2006,121](assumes normal distribution)
# Run complete. Total time: 00:18:23
Benchmark (N) Mode Cnt Score Error Units
ImmutableStringBenchmark.builderBenchmark 10 avgt ??? ± ??? us /op
ImmutableStringBenchmark.builderBenchmark 100 avgt 30 ?438 ± ?107 us /op
ImmutableStringBenchmark.builderBenchmark 1000 avgt 30 1?963 ± ?493 us /op
ImmutableStringBenchmark.builderBenchmark 10000 avgt ????407 ± ?039 us /op
ImmutableStringBenchmark.concatenationBenchmark 10 avgt ??? ± ??? us /op
ImmutableStringBenchmark.concatenationBenchmark 100 avgt 30 ?532 ± ?220 us /op
ImmutableStringBenchmark.concatenationBenchmark 1000 avgt ????002 ± ?759 us /op
ImmutableStringBenchmark.concatenationBenchmark 10000 avgt ????874 ± 84?652 us /op
MetricsFormatBenchmark.formatThroughBuilderBenchmark N /A avgt ????168 ± ?245 ns /op
MetricsFormatBenchmark.formatThroughConcatenationBenchmark N /A avgt 30 5?220 ± ?051 ns /op
MetricsFormatBenchmark.formatThroughMessageFormatBuilder N /A avgt ????952 ± 1?025 ns /op
MetricsFormatBenchmark.formatThroughPatternBenchmark N /A avgt ????698 ± 1?363 ns /op
OrdinalStringFormatBenchmark.formatThroughBuilderBenchmark N /A avgt 30 5?221 ± ?691 ns /op
OrdinalStringFormatBenchmark.formatThroughConcatenationBenchmark N /A avgt 30 6?486 ± ?936 ns /op
OrdinalStringFormatBenchmark.formatThroughMessageFormatBenchmark N /A avgt ????907 ± 1?414 ns /op
OrdinalStringFormatBenchmark.formatThroughPatternBenchmark N /A avgt ????689 ± 3?432 ns /op

 
Unexpected result! Perhaps even for those who closely followed the changes in Java 9: ​​ JEP-280 .
 
We look at the generated bytecode for MetricsFormat:
 
    public static java.lang.String formatThroughConcatenation (java.lang.String, int, long);
Code:
0: aload_0
1: iload_1
2: lload_2
3: invokedynamic # ? 0 //InvokeDynamic # 0: makeConcatWithConstants: (Ljava /lang /String; IJ) Ljava /lang /String;
8: areturn

 
and bytecode for OrdinalStringFormat:
 
    public static java.lang.String formatThroughConcatenation (java.lang.String, java.lang.String, java.lang.String, java.lang.String);
Code:
0: aload_0
1: aload_1
2: aload_2
3: aload_3
4: invokedynamic # ? 0 //InvokeDynamic # 0: makeConcatWithConstants: (Ljava /lang /String; Ljava /lang /String; Ljava /lang /String; Ljava /lang /String;) Ljava /lang /String;
9: areturn

 
For the generation of specialized methods makeConcatWithConstants meets StringConcatFactory . The specialization is that for each case a separate method is generated: for MetricsFormat was created. makeConcatWithConstants -method that takes String , int and long , and from the body MetricsFormat.formatThroughConcatenation () The loading of string constants (opcode ldc) is gone.
 
And then the JIT-compiler can well poke around, which turned out to be very noticeable for formatting the line with the metric - the result was better than StringBuilder 4 times!
 
But this can not always be obtained, as in the case of an example from our problem - the result is worse by about a quarter. The result turned out worse as relative to StringBuilder , and with respect to the result in Java 8.
 
 

Conclusion


 
Beyond the discussion were the compile-time optimization of concatenations, which can be read in the specification section, which has already been referenced previously (3r3r???.1 ), Which is also quite curious.
 
Excerpt from the specification [/b]
Example ???-1. String Concatenation
 
 
The example expression:
 
"The square root of 2 is" + Math.sqrt (2)

 
produces the result:
 
"The square root of 2 is ???"

 
 
The + operator is syntactically left-associative, no matter whether it is determined by type analysis or representations concatenation or numeric addition. In some cases care is required to get the desired result. For example, the expression:
 
a + b + c

 
is always considered as:
 
(a + b) + c

 
Therefore the result of the expression:
 
1 + 2 + "fiddlers"

 
is:
 
"3 fiddlers"

 
but the result of:
 
"Fiddlers" + 1 + 2

 
is:
 
"Fiddlers 12"

 

 
 
And left without attention uninhabited calls StringBuilder.append () and split into several independent concatenation actions. Although
 
Here for such methods
 
    public static String formatThroughConcatenation (String metrics, int value, long timestamp) {
String result = metrics + "";
result + = value + "";
result + = timest
return result;
}
public static String formatThroughBuilder (String metrics, int value, long timestamp) {
StringBuilder sb = new StringBuilder (metrics);
sb.append ("");
sb.append (value);
sb.append ("");
sb.append (timestamp);
return sb.toString ();
}

 
the bytecode is generated:
 
Bytecode [/b]
    public static java.lang.String formatThroughConcatenation (java.lang.String, int, long);
Code:
0: new # 7 //class java /lang /StringBuilder
3: dup
4: invokespecial # 8 //Method java /lang /StringBuilder. " " :() V
7: aload_0
8: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
11: ldc # 10 //String
13: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
16: invokevirtual # 11 //Method java /lang /StringBuilder.toString :() Ljava /lang /String;
19: ast ore 4
21: new # 7 //class java /lang /StringBuilder
24: dup
25: invokespecial # 8 //Method java /lang /StringBuilder. " " :() V
28: aload 4
30: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
33: iload_1
34: invokevirtual # 12 //Method java /lang /StringBuilder.append: (I) Ljava /lang /StringBuilder;
37: ldc # 10 //String
39: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
42: invokevirtual # 11 //Method java /lang /StringBuilder.toString :() Ljava /lang /String;
45: astore 4
47: new # 7 //class java /lang /StringBuilder
50: dup
51: invokespecial # 8 //Method java /lang /StringBuilder. " " :() V
54: aload 4
56: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
59: lload_2
60: invokevirtual # 13 //Method java /lang /StringBuilder.append: (J) Ljava /lang /StringBuilder;
63: invokevirtual # 11 //Method java /lang /StringBuilder.toString :() Ljava /lang /String;
66: astore 4
68: aload 4
70: areturn
public static java.lang.String formatThroughBuilder (java.lang.String, int, long);
Code:
0: new # 7 //class java /lang /StringBuilder
3: dup
4: aload_0
5: invokespecial # 14 //Method java /lang /StringBuilder. " ": (Ljava /lang /String;) V
8: astore 4
10: aload 4
12: ldc # 10 //String
14: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
17: pop
18: aload 4
20: iload_1
21: invokevirtual # 12 //Method java /lang /StringBuilder.append: (I) Ljava /lang /StringBuilder;
24: pop
25: aload 4
27: ldc # 10 //String
29: invokevirtual # 9 //Method java /lang /StringBuilder.append: (Ljava /lang /String;) Ljava /lang /StringBuilder;
32: pop
33: aload 4
35: lload_2
36: invokevirtual # 13 //Method java /lang /StringBuilder.append: (J) Ljava /lang /StringBuilder;
39: pop
40: aload 4
42: invokevirtual # 11 //Method java /lang /StringBuilder.toString :() Ljava /lang /String;
45: areturn

 
In both cases, it can be seen that javac has not made any attempts to optimize this. In the case of concatenation, 3 instances of StringBuilder are now created, the second method is also heavier.
 
How did this affect performance?
 
    Benchmark Mode Cnt Score Error Units
Metrics BuilderBenchmark avgt ????029 ± ?408 ns /op
Metrics ConcatenationBenchmark avgt ????483 ± 1?958 ns /op
Metrics MessageFormatBuilder avgt ????672 ± 1?152 ns /op
Metrics PatternBenchmark avgt ??? ± ??? ns /op

 
Results of the whole benchmark [/b]
    # JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughBuilderBenchmark
# Run progress: ???% complete, ETA 00:04:30
# Fork: 1 of 3
# Warmup Iteration 1: 27?429 ns /op
# Warmup Iteration 2: 19?309 ns /op
# Warmup Iteration 3: 19?026 ns /op
# Warmup Iteration 4: 20?715 ns /op
# Warmup Iteration 5: 21?038 ns /op
Iteration 1: 20?765 ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: ??? ns /op
Iteration 5: 19?417 ns /op
Iteration 6: 19?172 ns /op
Iteration 7: 19?825 ns /op
Iteration 8: 19?664 ns /op
Iteration 9: ??? ns /op
Iteration 10: 19?255 ns /op
# Run progress: ?33% complete, ETA 00:04:12
# Fork: 2 of 3
# Warmup Iteration 1: 26?478 ns /op
# Warmup Iteration 2: 18?885 ns /op
# Warmup Iteration 3: 19?952 ns /op
# Warmup Iteration 4: 19?522 ns /op
# Warmup Iteration 5: 18?620 ns /op
Iteration 1: 18?690 ns /op
Iteration 2: ??? ns /op
Iteration 3: 19?417 ns /op
Iteration 4: 18?153 ns /op
Iteration 5: 18?654 ns /op
Iteration 6: 19?455 ns /op
Iteration 7: 19?520 ns /op
Iteration 8: 19?637 ns /op
Iteration 9: 19?228 ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:03:49
# Fork: 3 of 3
# Warmup Iteration 1: 26?150 ns /op
# Warmup Iteration 2: 18?343 ns /op
# Warmup Iteration 3: 19?978 ns /op
# Warmup Iteration 4: 19?287 ns /op
# Warmup Iteration 5: 19?892 ns /op
Iteration 1: 19?412 ns /op
Iteration 2: 19?130 ns /op
Iteration 3: 19?759 ns /op
Iteration 4: 19?552 ns /op
Iteration 5: 19?657 ns /op
Iteration 6: 19?341 ns /op
Iteration 7: 19?031 ns /op
Iteration 8: 19?504 ns /op
Iteration 9: 20?200 ns /op
Iteration 10: 19?339 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughBuilderBenchmark":
19?029 ± (99.9%) ?408 ns /op[Average]
(min, avg, max) = (18?65? 19?02? 22?851), stdev = ?598
CI (99.9%):[191,621, 200,437](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughConcatenationBenchmark
# Run progress: ???% complete, ETA 00:03:26
# Fork: 1 of 3
# Warmup Iteration 1: 63?123 ns /op
# Warmup Iteration 2: 42?155 ns /op
# Warmup Iteration 3: 42?209 ns /op
# Warmup Iteration 4: ??? ns /op
# Warmup Iteration 5: 44?539 ns /op
Iteration 1: 42?996 ns /op
Iteration 2: 47?941 ns /op
Iteration 3: ??? ns /op
Iteration 4: 43?991 ns /op
Iteration 5: 45?734 ns /op
Iteration 6: ??? ns /op
Iteration 7: 43?390 ns /op
Iteration 8: ??? ns /op
Iteration 9: 45?826 ns /op
Iteration 10: ??? ns /op
# Run progress: 3?33% complete, ETA 00:03:03
# Fork: 2 of 3
# Warmup Iteration 1: 69?705 ns /op
# Warmup Iteration 2: 46?112 ns /op
# Warmup Iteration 3: 44?281 ns /op
# Warmup Iteration 4: 45?800 ns /op
# Warmup Iteration 5: 45?018 ns /op
Iteration 1: 43?737 ns /op
Iteration 2: 42?742 ns /op
Iteration 3: ??? ns /op
Iteration 4: 50?467 ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: 42?594 ns /op
Iteration 8: 46?360 ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:02:40
# Fork: 3 of 3
# Warmup Iteration 1: 63?491 ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: 44?987 ns /op
# Warmup Iteration 4: 43?363 ns /op
# Warmup Iteration 5: 42?921 ns /op
Iteration 1: ??? ns /op
Iteration 2: 42?941 ns /op
Iteration 3: 43?845 ns /op
Iteration 4: 42?774 ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: 44?060 ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughConcatenationBenchmark":
44?483 ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (42?99? 44?48? 51?239), stdev = 2?886
CI (99.9%):[428,524, 460,441](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughMessageFormatBuilder
# Run progress: 5?00% complete, ETA 00:02:17
# Fork: 1 of 3
# Warmup Iteration 1: 116?265 ns /op
# Warmup Iteration 2: 99?957 ns /op
# Warmup Iteration 3: 84?871 ns /op
# Warmup Iteration 4: 74?562 ns /op
# Warmup Iteration 5: 73?021 ns /op
Iteration 1: 73?366 ns /op
Iteration 2: 74?179 ns /op
Iteration 3: 72?182 ns /op
Iteration 4: 72?268 ns /op
Iteration 5: ??? ns /op
Iteration 6: 73?328 ns /op
Iteration 7: 73?186 ns /op
Iteration 8: 77?538 ns /op
Iteration 9: 81?751 ns /op
Iteration 10: 71?448 ns /op
# Run progress: 5?33% complete, ETA 00:01:54
# Fork: 2 of 3
# Warmup Iteration 1: ??? ns /op
# Warmup Iteration 2: 99?761 ns /op
# Warmup Iteration 3: 83?255 ns /op
# Warmup Iteration 4: 74?181 ns /op
# Warmup Iteration 5: 73?687 ns /op
Iteration 1: 74?292 ns /op
Iteration 2: ??? ns /op
Iteration 3: 74?853 ns /op
Iteration 4: 72?039 ns /op
Iteration 5: 73?011 ns /op
Iteration 6: 74?141 ns /op
Iteration 7: 73?273 ns /op
Iteration 8: 74?909 ns /op
Iteration 9: 73?629 ns /op
Iteration 10: 76?130 ns /op
# Run progress: ???% complete, ETA 00:01:31
# Fork: 3 of 3
# Warmup Iteration 1: 118?020 ns /op
# Warmup Iteration 2: 96?928 ns /op
# Warmup Iteration 3: 83?638 ns /op
# Warmup Iteration 4: 73?386 ns /op
# Warmup Iteration 5: 74?396 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: 73?421 ns /op
Iteration 4: 75?232 ns /op
Iteration 5: 73?976 ns /op
Iteration 6: 73?265 ns /op
Iteration 7: 74?118 ns /op
Iteration 8: 74?716 ns /op
Iteration 9: ??? ns /op
Iteration 10: 73?156 ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughMessageFormatBuilder":
??? ± (99.9%) 1?152 ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[730,520, 754,824](assumes normal distribution)
# JMH version: ???r3r33765. # VM version: JDK ???_16? VM ???-b12
# VM invoker: C: Program FilesJavajre???_161binjava.exe
# VM options:
# Warmup: 5 iterations, 1500 ms each
# Measurement: 10 iterations, 1500 ms each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time /op
# Benchmark: en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughPatternBenchmark
# Run progress: ???% complete, ETA 00:01:08
# Fork: 1 of 3
# Warmup Iteration 1: 223?607 ns /op
# Warmup Iteration 2: 170?927 ns /op
# Warmup Iteration 3: 152?384 ns /op
# Warmup Iteration 4: 149?499 ns /op
# Warmup Iteration 5: 143?785 ns /op
Iteration 1: 145?388 ns /op
Iteration 2: 147?134 ns /op
Iteration 3: ??? ns /op
Iteration 4: 146?800 ns /op
Iteration 5: ??? ns /op
Iteration 6: 145?507 ns /op
Iteration 7: ??? ns /op
Iteration 8: ??? ns /op
Iteration 9: ??? ns /op
Iteration 10: 149?234 ns /op
# Run progress: 8?33% complete, ETA 00:00:45
# Fork: 2 of 3
# Warmup Iteration 1: ??? ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: 140?303 ns /op
# Warmup Iteration 4: 140?054 ns /op
# Warmup Iteration 5: 141?979 ns /op
Iteration 1: 142?291 ns /op
Iteration 2: 141?831 ns /op
Iteration 3: 142?304 ns /op
Iteration 4: 141?528 ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: ??? ns /op
Iteration 8: 140?223 ns /op
Iteration 9: ??? ns /op
Iteration 10: ??? ns /op
# Run progress: ???% complete, ETA 00:00:22
# Fork: 3 of 3
# Warmup Iteration 1: 222?753 ns /op
# Warmup Iteration 2: ??? ns /op
# Warmup Iteration 3: 145?903 ns /op
# Warmup Iteration 4: 146?324 ns /op
# Warmup Iteration 5: 148?965 ns /op
Iteration 1: ??? ns /op
Iteration 2: ??? ns /op
Iteration 3: ??? ns /op
Iteration 4: ??? ns /op
Iteration 5: ??? ns /op
Iteration 6: ??? ns /op
Iteration 7: 146?299 ns /op
Iteration 8: ??? ns /op
Iteration 9: 148?246 ns /op
Iteration 10: ??? ns /op
Result "en.gnkoshelev.jbreak2018.perf_tests.strings.MetricsFormatBenchmark.formatThroughPatternBenchmark":
??? ± (99.9%) ??? ns /op[Average]
(min, avg, max) = (???? ???? ???), stdev = ???r3r33765. CI (99.9%):[1436,758, 1484,907](assumes normal distribution)
# Run complete. Total time: 00:04:35
Benchmark Mode Cnt Score Error Units
MetricsFormatBenchmark.formatThroughBuilderBenchmark avgt ????029 ± ?408 ns /op
MetricsFormatBenchmark.formatThroughConcatenationBenchmark avgt ????483 ± 1?958 ns /op
MetricsFormatBenchmark.formatThroughMessageFormatBuilder avgt ????672 ± 1?152 ns /op
MetricsFormatBenchmark.formatThroughPatternBenchmark avgt ????832 ± 2?075 ns /op

 
It is expected that the variant has got worse. MetricsFormat.formatThroughConcatenation () , but with the optimization of pop /aload in MetricsFormat.formatThroughBuilder () JIT-compiler coped perfectly - the result obtained on performance is no different from staged option.
 
 

P.S.


 
The code of benchmarks lies on github: jbreak2018-strings-perf-tests .
 
 
The final two parts will come out with a smaller lag. The third part will be released in the middle of the week.
+ 0 -

Add comment