Rcpp Version 1.0.9
overhead.r
Go to the documentation of this file.
1 #!/usr/bin/env r
2 
3 set.seed(42)
4 a <- rnorm(100)
5 b <- rnorm(100)
6 
7 ## load shared libraries with wrapper code
8 dyn.load("overhead_1.so")
9 dyn.load("overhead_2.so")
10 
11 overhead_c_symbol <- getNativeSymbolInfo( "overhead_c" )
12 overhead_cpp_symbol <- getNativeSymbolInfo( "overhead_cpp" )
13 
14 overhead_c <- function(a,b) .Call( overhead_c_symbol, a, b )
15 overhead_cpp <- function(a,b) .Call( overhead_cpp_symbol, a, b )
16 
17 ## load benchmarkin helper function
18 suppressMessages(library(rbenchmark))
19 
20 res <- benchmark(overhead_cpp(a,b), overhead_c(a,b),
21  columns=c("test", "replications", "elapsed", "relative", "user.self", "sys.self"),
22  order="relative",
23  replications=10000)
24 print(res)