[R] rJava call performance
dlieu.7 at gmail.com
Sat Mar 17 02:15:23 CET 2012
Another question: how do I ensure rJava is bytecode-compiled? I seem
to re-install the package with setting compilePKGS(T) before i install
it again, but most of rJava functions however seem to come back still
as not bytecode-compiled.
Thank you in advance.
On Fri, Mar 16, 2012 at 3:48 PM, Dmitriy Lyubimov <dlieu.7 at gmail.com> wrote:
> The "low level" seems to be much-much better though... not sure why
> the difference would be so fundamental...
> f <- function() system.time( for( i in 1:1000)
> .jcall("java/lang/Math", returnSig="D", "abs", as.numeric(i) ) )
> user system elapsed
> 0.080 0.000 0.083
> On Fri, Mar 16, 2012 at 3:27 PM, Dmitriy Lyubimov <dlieu.7 at gmail.com> wrote:
>> PS caching reference to the class doesn't change anything fundamentally:
>> clazz <- J("java.lang.Double")
>> system.time( for( i in 1:1000) clazz$ parseDouble(as.character(i)))
>> user system elapsed
>> 3.788 0.000 3.790
>> Java parsing is slow??? nope, still looking pretty appalling for what it does:
>>> clazz <- J("java.lang.Math")
>>> system.time( for( i in 1:1000) clazz$abs(i) )
>> user system elapsed
>> 3.492 0.000 3.497
>> On Fri, Mar 16, 2012 at 3:17 PM, Dmitriy Lyubimov <dlieu.7 at gmail.com> wrote:
>>> I am getting pretty poor rJava call performance
>>>> system.time(for (i in 1:1000) J("java.lang.Double")$parseDouble(as.character(i)))
>>> user system elapsed
>>> 4.884 0.000 4.900
>>> i.e. 5 milliseconds per very simple call on a very fast cpu. JNI calls
>>> themselves are said to be pretty fast nowadays (10...40ns). It
>>> probably goes accross reflection but still doing pretty much nothing
>>> useful in 5ms is horrible benchmark.
>>> Is that expected rJava performance? Cause if it is, this means it is
>>> completely usuitable for exchanging data with Java. ( I can probably
>>> bulk up data in data frames and pass it as a single call to do
>>> something with it but then either way i have to do conversion between
>>> bulk of R objects and bulk of java objects).
>>> Is there's a good performant way to do passing of data.frame's between
>>> java and back without having to do a native call for every row?
>>> Thank you.
More information about the R-help