<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">I got mOutput mixed up with mResults in the last message; it mResults that gets created up front and then every iteration. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L45">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L45</a><br></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"><br></div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Sep 23, 2018 at 5:38 AM Kyle Baron <<a href="mailto:kyleb@metrumrg.com">kyleb@metrumrg.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:small"><br></div><div 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 style="font-size:small"><br></div><div style="font-size:small">They also create mOutput and then re-create it every time it goes into InsideLoop</div><div><a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41</a></div><div><a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12</a><br></div><div><br></div><div>I just passed mOutput into InsideLoop and modified it there</div><div><a href="https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879" target="_blank">https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879</a><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div style="font-size:small"><br></div><div style="font-size:small"><br></div><div style="font-size:small"><br></div><div 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" target="_blank">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></blockquote></div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"></div></div>