Codereview request: 7109837 Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer

Ulf Zibis Ulf.Zibis at gmx.de
Fri Nov 25 00:34:16 UTC 2011


Sherman,

what is the magic behind, that the adler32 function runs faster on BirectBuffer than on byte[]?
Is it GetPrimitiveArrayCritical(env, b, 0) + ReleasePrimitiveArrayCritical(env, b, buf, 0) ?

Am 24.11.2011 23:47, schrieb Xueming Shen:
> Alan, Ulf,
>
> Webrev has been updated accordingly
>
> (1) {@code}
> (2) better wording for opening sentence as suggested
> (3) added -benhmark option for TimeCheckSum, so only do the benchmark run
>      (with 100000 iteration) when  this option is manually specified. Without the
>      option, it runs as a "normal"  regression test with iteration 1.
> (4) to use "ratio" of "time of ByteBuffer: time of byte[]" as
>     http://cr.openjdk.java.net/~sherman/7109837/benchmark
Reads much better :-)

>
> http://cr.openjdk.java.net/~sherman/7109837/webrev
Have you thought about overloading? :
void update(DirectBuffer buffer) +
void update(ByteBuffer buffer)
It would save the instanceof and the cast.
At least I would like to see a note in the javadoc, that using DirectBuffer in doubt would be faster 
than HeapBuffer.

Isn't
     adler32.update(buf.array(), buf.position(), buf.remaining());
     buf.flip();
faster than
     adler32.update(buf);
?

Additionally I'm wondering, if there are Buffers which are not direct and dont't have array().

-Ulf




More information about the core-libs-dev mailing list