<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">El dom., 23 sept. 2018 13:01, Iñaki Ucar <<a href="mailto:iucar@fedoraproject.org">iucar@fedoraproject.org</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also you can try adding<br>
<br>
// [[Rcpp::plugins(unwindProtect)]]<br>
<br>
to InsideLoop.cpp. That should boost the performance too with the<br>
latest version of Rcpp.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Taking a look now, and I realize there are just calls to C++, not to R. So, please, forget about what I've said. The dangers of skimming through code in a mobile device and speaking too soon.</div><div dir="auto"><br></div><div dir="auto">Iñaki</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Iñaki</blockquote></div></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
El dom., 23 sept. 2018 a las 12:46, Kyle Baron (<<a href="mailto:kyleb@metrumrg.com" target="_blank" rel="noreferrer">kyleb@metrumrg.com</a>>) escribió:<br>
><br>
><br>
> I got mOutput mixed up with mResults in the last message; it mResults that gets created up front and then every iteration.<br>
><br>
> <a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L45" rel="noreferrer noreferrer" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L45</a><br>
> <a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12" rel="noreferrer noreferrer" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12</a><br>
><br>
><br>
><br>
><br>
><br>
> On Sun, Sep 23, 2018 at 5:38 AM Kyle Baron <<a href="mailto:kyleb@metrumrg.com" target="_blank" rel="noreferrer">kyleb@metrumrg.com</a>> wrote:<br>
>><br>
>><br>
>> 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<br>
>><br>
>> They also create mOutput and then re-create it every time it goes into InsideLoop<br>
>> <a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41" rel="noreferrer noreferrer" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41</a><br>
>> <a href="https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12" rel="noreferrer noreferrer" target="_blank">https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12</a><br>
>><br>
>> I just passed mOutput into InsideLoop and modified it there<br>
>> <a href="https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879" rel="noreferrer noreferrer" target="_blank">https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> On Sat, Sep 22, 2018 at 1:21 PM Dirk Eddelbuettel <<a href="mailto:edd@debian.org" target="_blank" rel="noreferrer">edd@debian.org</a>> wrote:<br>
>>><br>
>>><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 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 noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank" rel="noreferrer">edd@debian.org</a><br>
>>> _______________________________________________<br>
>>> Rcpp-devel mailing list<br>
>>> <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank" rel="noreferrer">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 noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
>><br>
>><br>
>><br>
>><br>
> _______________________________________________<br>
> Rcpp-devel mailing list<br>
> <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank" rel="noreferrer">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 noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<br>
<br>
<br>
-- <br>
Iñaki Ucar<br>
</blockquote></div></div></div>