3940414243444546474849
b.mark("begin"); for (int i = 0; i < times; i++) { base.getBytes(); } b.mark("after " + times); b.done(); } @Test public void testStringToWrapByteBuffer() { Benchmark b = new Benchmark("String wrap ByteBuf");
5152535455565758596061
b.mark("begin"); for (int i = 0; i < times; i++) { ByteBuffer.wrap(base.getBytes()); } b.mark("after " + times); b.done(); } @Test public void testStringtoByteBufferCopy() {
6667686970717273747576
byte[] buf = base.getBytes(); ByteBuffer bb = ByteBuffer.allocate(buf.length); bb.put(buf); } b.mark("after " + times); b.done(); } @Test public void testStringToByteArray2() { Benchmark b = new Benchmark("String to ByteArray");
7879808182838485868788
b.mark("begin"); for (int i = 0; i < times; i++) { base.getBytes(); } b.mark("after " + times); b.done(); } @Test public void testStringToWrapByteBuffer2() { Benchmark b = new Benchmark("String wrap ByteBuf");
90919293949596979899100
b.mark("begin"); for (int i = 0; i < times; i++) { ByteBuffer.wrap(base.getBytes()); } b.mark("after " + times); b.done(); } @Test public void testStringtoByteBufferCopy2() {
105106107108109110111112113
byte[] buf = base.getBytes(); ByteBuffer bb = ByteBuffer.allocate(buf.length); bb.put(buf); } b.mark("after " + times); b.done(); } }
4748495051525354555657
for (int i = 0; i < times; i++) { @SuppressWarnings("unused") String temp = base + i; } b.mark("after " + times); b.done(); } @Test public void testStringBufferAppend() { StringBuffer buf = new StringBuffer(base);
6061626364656667686970
b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done(); } @Test public void testStringBuilderAppend() { StringBuilder buf = new StringBuilder(base);
7374757677787980818283
b.mark("begin"); for (int i = 0; i < times; i++) { buf.append(i); } b.mark("after " + times); b.done(); } @Test public void testStringFormat() { String format = "%s%d";
8687888990919293949596
b.mark("begin"); for (int i = 0; i < times; i++) { String.format(format, base, i); } b.mark("after " + times); b.done(); } @Test public void testStringAppend2() {