<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It seems like the sourceCpp thing is the biggie.  That dropped about a second of the time from something like 2.7 to 1.7 seconds</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">They also create mOutput and then re-create it every time it goes into InsideLoop</div><div class="gmail_default"><a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41</a></div><div class="gmail_default"><a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">I just passed mOutput into InsideLoop and modified it there</div><div class="gmail_default"><a href="https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879">https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879</a><br></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 22, 2018 at 1:21 PM Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
On 22 September 2018 at 12:36, Michael Weylandt wrote:<br>
| I don't have time right now, but the offending line is here:<br>
| <br>
| <a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L62" rel="noreferrer" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L62</a><br>
| <br>
| which calls `sourceCpp` repeatedly on each loop iteration.<br>
| <br>
| Should be a one line change to move it outside the loop and un-sully the<br>
| good name of Rcpp.<br>
<br>
Nice catch!!  You should _definitely_ send him a PR. I also suggest to move<br>
the sourceCpp() outside the timed segment as I do not think he accounts for<br>
compilation in the other approaches (eg C++).<br>
<br>
Dirk<br>
<br>
-- <br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><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><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><table style="color:rgb(0,0,0);font-family:-webkit-standard;border:none;border-collapse:collapse"><colgroup><col width="67"><col width="353"></colgroup><tbody><tr style="height:0pt"><td style="border:1pt solid rgb(255,255,255);vertical-align:top;padding:5pt"><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh5.googleusercontent.com/Nrlw-WqbvgX4IHzoumG-lOHMj0jIGLTTozhSsZirRCQaPp-rDI-6bysp9ULRX3Qu12k_JUs_rgUVCX_e9xLSG4MecxdO2FTlGLyy0me8CHjH43REuampI6BhF50w4oFJi1TDpGOS" width="57" height="46" style="border:none"></span></p></td><td style="border:1pt solid rgb(255,255,255);vertical-align:top;padding:5pt"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10pt;font-family:Arial;background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">Kyle Baron | Principal Scientist I</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Metrum Research Group</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">2 Tunxis Road | Tariffville, CT 06081</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10pt;font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">p: 860-735-7043 ext. 202 | e: <a href="mailto:kyleb@metrumrg.com" target="_blank">kyleb@metrumrg.com</a></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><a href="https://info.metrumrg.com/contact" style="text-decoration:none" target="_blank"><span style="font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh6.googleusercontent.com/Zq7Io9hKXj6KRwrK8doxyHkvDU-uDi9LwpByIXsbprEE1lG9Ys8mxnvnsN7iSKb9ZsTHHxa2QWh0EIXxGrN5i5OjBSvr0BWVFQ1TqPLxVdNUozKQbibweC_uleXiVK0q3Ka8Bh9F" width="128" height="27" style="border:none"></span></a><a href="https://www.linkedin.com/company/metrum-research-group-llc/" style="text-decoration:none" target="_blank"><span style="font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh5.googleusercontent.com/5r6O3e3CYXSEV8B0ooDvpxug2ieUAAvPLcJpuXw95nzU8JI5dMzzx-vDFNIjQG1U4_RIyTWI8LVCAKCBwC9wJJWQOT6EA5hKk0tuZmW_rC-iXmj1Ojb4ajyjep9AyPDUNCf-rlG-" width="28" height="28" style="border:none"></span></a><a href="https://twitter.com/MetrumRG" style="text-decoration:none" target="_blank"><span style="font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><img src="https://lh3.googleusercontent.com/GyHD5E9oNfoe_fE7Q-XyvfpNg8-qNAODePFQaxWtEpPw1PbbfZBe3iO6KTPmiojQg_3YDCvh6A8v7KOZvNC5kjpwLWkvXUTFYrdFBUggrB8oLH7ycKhhg0hwD7hnDa4X9_VmBPN1" width="28" height="28" style="border:none"></span></a></p></td></tr></tbody></table></div></div>