Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 14:21:39 +0100
Robert Klemme wrote:
> > [me]
> > You could always write custom array operations in JNI. Otherwise the
> > answer is no (not without a change to the JVM design, which isn't
> > going to happen).
>
> I'm not sure whether array accesses via JNI actually bypass bounds checks.
It does. The way the JNI interfaces work (for arrays of primitive types --
which are the only kind worth considering in this context) the API gives you
(at its choice) either a pointer to the data (which you have to return
explicitly) or a pointer to a temporary copy of the data (which you also have
to return). In either case access to the individual elements is at full memory
speed. There is no need to issue a JNI call for each array access.
Also note that it is very unlikely that the overhead of copying (if it happens
at all) would matter. Copying is O(n), but unless the operation itself were
significantly more expensive than O(n) there would be no point in optimising
it.
-- chris
.
- Follow-Ups:
- References:
- To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Casey Hawthorne
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Chris Uppal
- Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- From: Robert Klemme
- To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Prev by Date: Re: Software Engineers required for USA
- Next by Date: Re: Yet Another Web Application Mess...
- Previous by thread: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Next by thread: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Index(es):
Relevant Pages
|