Open JohnCoene opened 3 months ago
foo <- function(x = 2) x + 1
rbenchmark::benchmark("fn" = {foo();foo();foo()}, "macro" = {2 + 1; 2 + 1; 2
+ 1}, replications = 1000)
test replications elapsed relative user.self sys.self user.child sys.child
1 fn 1000 0.002 2 0.002 0 0 0
2 macro 1000 0.001 1 0.001 0 0 0
A text replacement macro a la C is a bit meh but perhaps a start?
Could we have macros? Are they worth it? What's the runtime overhead of calling a function in R.