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

Dirk Eddelbuettel edd at debian.org
Mon Aug 27 19:16:18 CEST 2012


On 27 August 2012 at 11:31, Peng Yu wrote:
| The following code shows that inline function is over 10 times faster
| than .Call and calling .Call directly is slower than call .Call by
| wrapping it in another function. Is this expected?

inlines uses .Call, so there is a slight logical problem here...  And yes,
functions have overheads.


| library(microbenchmark)
| microbenchmark(test(xx))
| microbenchmark(test_inline(xx))
| microbenchmark(.Call('test', xx))

The normal idiom is a _single_ call so that you can compare:

  microbenchmark(test(xx), test_inline(xx), .Call('test', xx))


Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list