File: overhead.r

package info (click to toggle)
rcpp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,480 kB
  • sloc: cpp: 27,436; ansic: 7,778; sh: 53; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 717 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env r

set.seed(42)
a <- rnorm(100)
b <- rnorm(100)

## load shared libraries with wrapper code
dyn.load("overhead_1.so")
dyn.load("overhead_2.so")

overhead_c_symbol <- getNativeSymbolInfo( "overhead_c" )
overhead_cpp_symbol <- getNativeSymbolInfo( "overhead_cpp" )

overhead_c <- function(a,b) .Call( overhead_c_symbol, a, b )
overhead_cpp <- function(a,b) .Call( overhead_cpp_symbol, a, b )

## load benchmarkin helper function
suppressMessages(library(rbenchmark))

res <- benchmark(overhead_cpp(a,b), overhead_c(a,b),
                 columns=c("test", "replications", "elapsed", "relative", "user.self", "sys.self"),
                 order="relative",
                 replications=10000)
print(res)