<div dir="ltr">I think this is mostly because we still haven't ported the majority of usages of Rcpp_eval() to the new Rcpp_fast_eval(), so by default users are still getting the slower Rcpp_eval(). Compare e.g.<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>Rcpp::sourceCpp(code='</div></div><div><div>  #include <Rcpp.h></div></div><div><div>  using namespace Rcpp;</div></div><div><div><br></div></div><div><div>  // [[Rcpp::export]]</div></div><div><div>  void Rcpp_eval_old(SEXP expr, int n) {</div></div><div><div>    for (int i = 0; i < n; i++)    </div></div><div><div>      Rcpp_eval(expr, R_GlobalEnv);</div></div><div><div>  }'</div></div><div><div>)</div></div><div><div><br></div></div><div><div>Rcpp::sourceCpp(code='</div></div><div><div>  #define RCPP_PROTECTED_EVAL</div></div><div><div>  #include <Rcpp.h></div></div><div><div>  using namespace Rcpp;</div></div><div><div><br></div></div><div><div>  // [[Rcpp::export]]</div></div><div><div>  void Rcpp_eval_new(SEXP expr, int n) {</div></div><div><div>    for (int i = 0; i < n; i++)</div></div><div><div>       Rcpp_fast_eval(expr, R_GlobalEnv);</div></div><div><div>  }')</div></div><div><div><br></div></div><div><div>system.time(Rcpp_eval_old(quote(1 + 1), 1E5L))</div></div><div><div>system.time(Rcpp_eval_new(quote(1 + 1), 1E5L))</div></div></blockquote><div><div><br></div><div>I get:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>> system.time(Rcpp_eval_old(quote(1 + 1), 1E5L))</div></div></div><div><div><div>   user  system elapsed </div></div></div><div><div><div>  1.198   0.003   1.203 </div></div></div><div><div><div>> system.time(Rcpp_eval_new(quote(1 + 1), 1E5L))</div></div></div><div><div><div>   user  system elapsed </div></div></div><div><div><div>  0.118   0.034   0.151 </div></div></div></blockquote><div><div><br></div><div>We'll take a closer look next week.</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Jun 9, 2018 at 4:40 AM Iñaki Úcar <<a href="mailto:i.ucar86@gmail.com">i.ucar86@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I've followed with interest the development of the new evaluation API.<br>
Now that it's finally merged, I was testing it. Perhaps I'm mistaken,<br>
but shouldn't we expect a performance improvement in code such as the<br>
following?<br>
<br>
Rcpp::sourceCpp(code='<br>
  #include <Rcpp.h><br>
  using namespace Rcpp;<br>
<br>
  // [[Rcpp::export]]<br>
  void old_api(Function func, int n) {<br>
    for (int i=0; i<n; i++) func();<br>
  }'<br>
)<br>
<br>
Rcpp::sourceCpp(code='<br>
  #define RCPP_PROTECTED_EVAL<br>
  #include <Rcpp.h><br>
  using namespace Rcpp;<br>
<br>
  // [[Rcpp::export]]<br>
  void new_api(Function func, int n) {<br>
    for (int i=0; i<n; i++) func();<br>
  }'<br>
)<br>
<br>
func <- function() 1<br>
system.time(old_api(func, 1e5))<br>
system.time(new_api(func, 1e5))<br>
<br>
Regards,<br>
Iñaki<br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></blockquote></div></div></div>