Closed wleoncio closed 1 year ago
For communicating with Julia, the JuliaConnectoR uses TCP. This requires IO operations which will add to the execution time. Standard operations like matrix multiplication or matrix inversion are already highly optimized in R and the differences to Julia will be only minimal. The IO operations is simply much slower than the execution of these highly optimized functions on memory. You won't get a benefit from Julia or the JuliaConnectoR in this case. You can only expect an advantage over R if you have larger portions of code in Julia that cannot be optimized that much in R.
Thank you for the explanation. My intention is to eventually replace the simple functions above with more complicated ones that simulate real usage in our workplace. Perhaps I should go straight to those, though I did hope to be able to show that all three languages performed at the same order of magnitude for the simpler example.
With the JuliaConnectoR, you have some more communication overhead for the IO via TCP. So you can't use it to measure the Julia performance itself via measuring the execution time of the whole operation in R.
I see. In any case, I guess the example in my OP is a good counterexample (for when using a second language is not worth the effort).
FWIW, I just implemented a more complex example using linear search (inspired by this post) and got the performance differences I was expecting. \o/
I see. In any case, I guess the example in my OP is a good counterexample (for when using a second language is not worth the effort).
Yes, exactly.
FWIW, I just implemented a more complex example using linear search (inspired by this post) and got the performance differences I was expecting. \o/
Great to hear! Thanks for the link to the post.
I'm writing a short script to compare the performance of Julia against C++ and R, using an R script as the main file reproduced below:
Created on 2022-12-14 with reprex v2.0.2
I am wondering why Julia is performing so poorly. My only guesses had to do with unnecessary recompilation of code or of Julia instances but using
startJuliaServer()
/stopJulia()
doesn't help, and neither does isolating the functions in their own source files. What am I missing?