5051525354555657585960
b.mark("begin"); for (int i = 0; i < times; i++) { ByteBuffer.wrap(base.getBytes()); } b.mark("after " + times); b.done(); } @Test
5960616263646566676869
@Test public void testStringtoByteBufferCopy() { Benchmark b = new Benchmark("String alloc ByteBuf"); b.mark("begin"); for (int i = 0; i < times; i++) { byte[] buf = base.getBytes(); ByteBuffer bb = ByteBuffer.allocate(buf.length); bb.put(buf); }
6566676869707172737475
for (int i = 0; i < times; i++) { byte[] buf = base.getBytes(); ByteBuffer bb = ByteBuffer.allocate(buf.length); bb.put(buf); } b.mark("after " + times); b.done(); } @Test public void testStringToByteArray2() {
7374757677787980818283
@Test public void testStringToByteArray2() { Benchmark b = new Benchmark("String to ByteArray"); b.mark("begin"); for (int i = 0; i < times; i++) { base.getBytes(); } b.mark("after " + times); b.done();
7778798081828384858687
b.mark("begin"); for (int i = 0; i < times; i++) { base.getBytes(); } b.mark("after " + times); b.done(); } @Test public void testStringToWrapByteBuffer2() {
8586878889909192939495
@Test public void testStringToWrapByteBuffer2() { Benchmark b = new Benchmark("String wrap ByteBuf"); b.mark("begin"); for (int i = 0; i < times; i++) { ByteBuffer.wrap(base.getBytes()); } b.mark("after " + times); b.done();
8990919293949596979899
9899100101102103104105106107108
@Test public void testStringtoByteBufferCopy2() { Benchmark b = new Benchmark("String alloc ByteBuf"); b.mark("begin"); for (int i = 0; i < times; i++) { byte[] buf = base.getBytes(); ByteBuffer bb = ByteBuffer.allocate(buf.length); bb.put(buf); }
104105106107108109110111112113
for (int i = 0; i < times; i++) { byte[] buf = base.getBytes(); ByteBuffer bb = ByteBuffer.allocate(buf.length); bb.put(buf); } b.mark("after " + times); b.done(); } }
4142434445464748495051
@Test public void testStringAppend() { 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);