[Rcpp-devel] Why inline function is much faster than .Call?

Bob Carpenter carp at alias-i.com
Mon Aug 27 23:50:17 CEST 2012



On 8/27/12 4:27 PM, Douglas Bates wrote:

> Dirk is trying to point out that the two calls are using the same
> mechanism.  All that the inline package does is wrap the process of
> compiling, linking and dynamically loading the C++ function.
> Executing a function compiled this way is exactly the same as
> executing a function compiled separately.

One way they could differ is in optimization level specified
on the compiler.

> Benchmarking a function like this only once is liable to be unreliable
> because the current state of the garbage collection and heap
> allocation can change running times.  It is better to run the function
> a couple of times before benchmarking.

This can depend on the use case.

Running the same process multiple times can lead to
disk data caching or even memory data caching, leading
to overestimates of speed in real-life situations where
the data's not cached.

The other thing that can happen is that two approaches
have different latencies and throughputs.  One may
be slow to start, but fast to run.  Another may be
fast to start, but relatively slow to run.  (An example
is the total time to compile + run at different optimization
levels and data sizes.)

- Bob



More information about the Rcpp-devel mailing list