Skip to content

Internal usage of Rcpp_fast_eval in Rcpp #866

@thirdwing

Description

@thirdwing

This has been discussed on the Rcpp mailing list: http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2018-June/010029.html

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions