[Rcpp-devel] Why inline function is much faster than .Call?
Dirk Eddelbuettel
edd at debian.org
Tue Aug 28 20:18:20 CEST 2012
For completeness, on Linux I get (with thanks to Davor providing his package;
and omitting compiler warnings over signed/unsigned comparisons in Peng's
code) the following:
edd at max:/tmp$ r pengyu3.r
test replications elapsed relative user.self
2 test_inline(xx) 1000 6.173 1.000000 6.144
3 .Call("test", xx, package = "test") 1000 6.228 1.008910 6.217
1 test(xx) 1000 6.657 1.078406 6.280
edd at max:/tmp$
edd at max:/tmp$ r pengyu3.r
test replications elapsed relative user.self
2 test_inline(xx) 1000 6.177 1.000000 6.152
3 .Call("test", xx, package = "test") 1000 6.180 1.000486 6.169
1 test(xx) 1000 6.485 1.049862 6.132
edd at max:/tmp$
So even with 1000 replications, the inter-experiment variation is still large
and almost as big as the difference between the second and third method
itself.
All told, inline has a slight edge, and the simple layer of an additional
function call in test() --- which does nothing but the .Call() we also run
directly -- dominates. That doesn't take away from the fact that just about
every experienced R user will recommend use of a package.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list