[Rcpp-devel] rcpp overhead

Jared Murray jmurray.1022 at gmail.com
Sun Mar 11 15:34:51 CET 2012


I don't have the answer to his question, but it looks like he's not
comparing R to Rcpp/C++ but rather "pure" C++ to Rcpp/C++. And the
suspect code he posted isn't doing anything obviously (to me) silly,
like repeatedly calling back into R (of course it would have bigger
problems trying to do that in pure C++ :) )

My thoughts would be to match the compiler options exactly (maybe
something is optimized in one case but not the other?). Also make sure
that the execution time is long enough so that actual work dominates,
and do as many replications as you can. As mentioned previously it
could be a simple problem with how you're timing the code as well, but
I can't speak to that.

A 2x difference just from wrapping your code with Rcpp seems extreme
to me, but I've never measured...

Best,
-Jared

On Sat, Mar 10, 2012 at 8:09 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 11 March 2012 at 01:33, Kaveh Vakili wrote:
> |
> | >Don't take this the wrong way, but we are not here to debug or rewrite your
> | >code for you.
> |
> |
> | Thanks Dirk, but i'm not asking for this either.
> |
> | The code works....only it doesn't time the same.
> | My question is: is it normal -- is there an
> | overhead in using rcpp and how large is it,
> | typically?
> |
> | I'm was not even so enclined to post my code
> | --my question is more general.
>
> In that case you get a firm "maybe" in reply.
>
> You need to understand that there is still nothing for us to go on.  Define
> overhead. Relative to what? Do you expect calls of compiled functions to be
> faster or slower than interpreted? What about recursion?
>
> Do your homework, and come back with a well-formed question with measurable
> objectives. Everything else is just chitchat suitable for a campfire.
>
> And again, if you care to _read_ the archives you will find different people
> posting different result with speed increases ranging anywhere from a 'few
> times faster' to 'ten (and more) times faster' up to to an increase of
> several hundred times on a arguably degenerate problem (of a fibonacci
> recursion).
>
> But people also do silly things (eg calling R back each time) and expect it
> to be faster.  No mas -- this ain't magic pixie dust. If you use it the wrong
> way, you get out what you put in.
>
> Dirk
>
> --
> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
> dark to read." -- Groucho Marx
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


More information about the Rcpp-devel mailing list