Iñaki Úcar
2018-06-09 11:39:48 UTC
Hi all,
I've followed with interest the development of the new evaluation API.
Now that it's finally merged, I was testing it. Perhaps I'm mistaken,
but shouldn't we expect a performance improvement in code such as the
following?
Rcpp::sourceCpp(code='
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void old_api(Function func, int n) {
for (int i=0; i<n; i++) func();
}'
)
Rcpp::sourceCpp(code='
#define RCPP_PROTECTED_EVAL
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void new_api(Function func, int n) {
for (int i=0; i<n; i++) func();
}'
)
func <- function() 1
system.time(old_api(func, 1e5))
system.time(new_api(func, 1e5))
Regards,
Iñaki
I've followed with interest the development of the new evaluation API.
Now that it's finally merged, I was testing it. Perhaps I'm mistaken,
but shouldn't we expect a performance improvement in code such as the
following?
Rcpp::sourceCpp(code='
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void old_api(Function func, int n) {
for (int i=0; i<n; i++) func();
}'
)
Rcpp::sourceCpp(code='
#define RCPP_PROTECTED_EVAL
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void new_api(Function func, int n) {
for (int i=0; i<n; i++) func();
}'
)
func <- function() 1
system.time(old_api(func, 1e5))
system.time(new_api(func, 1e5))
Regards,
Iñaki