[Rcpp-devel] Question on performance

Iñaki Ucar iucar at fedoraproject.org
Sun Sep 23 13:01:13 CEST 2018


Also you can try adding

// [[Rcpp::plugins(unwindProtect)]]

to InsideLoop.cpp. That should boost the performance too with the
latest version of Rcpp.

Iñaki

El dom., 23 sept. 2018 a las 12:46, Kyle Baron (<kyleb at metrumrg.com>) escribió:
>
>
> I got mOutput mixed up with mResults in the last message; it mResults that gets created up front and then every iteration.
>
> https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L45
> https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12
>
>
>
>
>
> On Sun, Sep 23, 2018 at 5:38 AM Kyle Baron <kyleb at metrumrg.com> wrote:
>>
>>
>> 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
>>
>> They also create mOutput and then re-create it every time it goes into InsideLoop
>> https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L41
>> https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/InsideLoop.cpp#L12
>>
>> I just passed mOutput into InsideLoop and modified it there
>> https://github.com/kylebmetrum/Comparison-Programming-Languages-Economics/commit/89015a72a0cf673739e83e38d4a545db4886b879
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Sat, Sep 22, 2018 at 1:21 PM Dirk Eddelbuettel <edd at debian.org> wrote:
>>>
>>>
>>> On 22 September 2018 at 12:36, Michael Weylandt wrote:
>>> | I don't have time right now, but the offending line is here:
>>> |
>>> | https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Rcpp.R#L62
>>> |
>>> | which calls `sourceCpp` repeatedly on each loop iteration.
>>> |
>>> | Should be a one line change to move it outside the loop and un-sully the
>>> | good name of Rcpp.
>>>
>>> Nice catch!!  You should _definitely_ send him a PR. I also suggest to move
>>> the sourceCpp() outside the timed segment as I do not think he accounts for
>>> compilation in the other approaches (eg C++).
>>>
>>> Dirk
>>>
>>> --
>>> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>>> _______________________________________________
>>> Rcpp-devel mailing list
>>> Rcpp-devel at lists.r-forge.r-project.org
>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>
>>
>>
>>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel



-- 
Iñaki Ucar


More information about the Rcpp-devel mailing list