4647484950515253545556
b.mark("begin"); for (int i = 0; i < times; i++) { @SuppressWarnings("unused") String temp = base + i; } b.mark("after " + times); b.done(); } @Test public void testStringBufferAppend() {
5556575859606162636465
@Test public void testStringBufferAppend() { StringBuffer buf = new StringBuffer(base); Benchmark b = new Benchmark("StringBuffer Append"); b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done();
5960616263646566676869
b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done(); } @Test public void testStringBuilderAppend() {
6869707172737475767778
@Test public void testStringBuilderAppend() { StringBuilder buf = new StringBuilder(base); Benchmark b = new Benchmark("StringBuffer Append"); b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done();
7273747576777879808182
b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done(); } @Test public void testStringFormat() {
8182838485868788899091
@Test public void testStringFormat() { String format = "%s%d"; Benchmark b = new Benchmark("StringFormatAppend"); b.mark("begin"); for (int i = 0; i < times; i++) { String.format(format, base, i); } b.mark("after " + times); b.done();
8586878889909192939495
b.mark("begin"); for (int i = 0; i < times; i++) { String.format(format, base, i); } b.mark("after " + times); b.done(); } @Test
949596979899100101102103104
@Test public void testStringAppend2() { Benchmark b = new Benchmark("String Append"); b.mark("begin"); for (int i = 0; i < times; i++) { @SuppressWarnings("unused") String temp = base + i; } b.mark("after " + times);
99100101102103104105106107108109
b.mark("begin"); for (int i = 0; i < times; i++) { @SuppressWarnings("unused") String temp = base + i; } b.mark("after " + times); b.done(); } @Test public void testStringBufferAppend2() {
108109110111112113114115116117118
@Test public void testStringBufferAppend2() { StringBuffer buf = new StringBuffer(base); Benchmark b = new Benchmark("StringBuffer Append"); b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done();