Created
June 19, 2018 18:38
-
-
Save attilapiros/730d67b62317d14f5fd0f6779adea245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void speedTest() { | |
int n = 500; | |
int oneBuffSize = 100000; | |
System.out.println("n = " + n); | |
byte buffArray[][] = new byte[n][]; | |
for (int j = 0; j < n; j++) { | |
byte buff0[] = new byte[oneBuffSize]; | |
for (int i = 0; i < oneBuffSize; i++) { | |
buff0[i] = (byte) (i % 12); | |
} | |
buffArray[j] = buff0; | |
} | |
System.out.println("duration221 = " + durationOfSend(n, Unpooled.wrappedBuffer(buffArray), oneBuffSize)); | |
System.out.println("duration221.new = " + durationOfNewSend(n, Unpooled.wrappedBuffer(buffArray), oneBuffSize)); | |
System.out.println("duration230 = " + durationOfSend(n, Unpooled.wrappedBuffer(n, buffArray), oneBuffSize)); | |
System.out.println("duration230.new = " + durationOfNewSend(n, Unpooled.wrappedBuffer(n, buffArray), oneBuffSize)); | |
} | |
private long durationOfSend(int n, ByteBuf bb, int oneBuffSize) { | |
long start = System.currentTimeMillis(); | |
for (int j = 0; j < n; j++) { | |
bb.nioBuffer(); | |
bb.skipBytes(oneBuffSize); | |
} | |
return System.currentTimeMillis() - start; | |
} | |
private long durationOfNewSend(int n, ByteBuf bb, int oneBuffSize) { | |
long start = System.currentTimeMillis(); | |
for (int j = 0; j < n; j++) { | |
bb.nioBuffer(0, oneBuffSize-1); | |
bb.skipBytes(oneBuffSize); | |
} | |
return System.currentTimeMillis() - start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment