public void testIntPerformance() throws Exception { ByteBuffer b1 = ByteBuffer.allocate(5).put(0, DSCODE.INTEGER); ByteBuffer b2 = ByteBuffer.allocate(5).put(0, DSCODE.INTEGER); for (int n = 0; n < 5; n++) { long diff = 0; int count = 10000000; long start = System.nanoTime(); for (int i = 0; i < count; i++) { b1.putInt(1, i); b2.putInt(1, i + 1); diff += lc.compare(b1.array(), b1.arrayOffset(), b1.capacity(), b2.array(), b2.arrayOffset(), b2.capacity()); } long nanos = System.nanoTime() - start; System.out.printf("(%d) %f int comparisons / ms\n", diff, 1000000.0 * count / nanos); diff = 0; start = System.nanoTime(); for (int i = 0; i < count; i++) { b1.putInt(1, i); b2.putInt(1, i + 1); diff += Bytes.compareTo(b1.array(), b1.arrayOffset(), b1.capacity(), b2.array(), b2.arrayOffset(), b2.capacity()); } nanos = System.nanoTime() - start; System.out.printf("(%d) %f byte comparisons / ms\n\n", diff, 1000000.0 * count / nanos); } }