David Daney wrote:
Roman Kennke wrote:

Hi again,


On most free JVMs that I know of (libgcj), array accesses are much faster than the corresponding actions on a java.nio.Buffer.



I don't think so. The normal bytebuffer is also only an array. The
accessor methods should not make much difference.


The key difference is that, in gcj for example, an array access is translated in to a machine instruction that directly accesses the desired element. Access through a java.nio.Buffer involves at least one function call which is a much heavier weight operation.



Ok. I can see that. (You should patch GCJ to recognize calls to
ByteBuffer and replace that with array access -- and calls to a direct
ByteBuffer with raw memory access if that's any difference).


It is on my list.  However I probably will not get to it this year.


However, if you look at the old code you'll see that we did use Buffers
even there. And copy from array into buffer and back. This is cleaned up
by this patch a little and also removed some copies and allocations.
I'll benchmark it this evening and see what comes out of it.


Thanks. I could run a benchmark for you on gcj, but unfortunatly not until the end of next week.


Well maybe not. Tom Tromey just pointed out that libgcj overrides this code so currently the patch would not effect libgcj.

David Daney

Reply via email to