[R] rJava call performance

Dmitriy Lyubimov dlieu.7 at gmail.com
Fri Mar 16 23:17:20 CET 2012


Hello,

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.
-Dmitriy



More information about the R-help mailing list