[Rcpp-devel] optimizing rcpp iterating code

Krzysztof Sakrejda krzysztof.sakrejda at gmail.com
Wed Jul 16 20:18:26 CEST 2014


Hi Steve,

One way to get a boost is to avoid allocating memory, so your second
message is spot on.  If you are serious about making your code fast
you need to get used to profiling your code. When it's a
small-to-medium bit like this it might not be necessary, but in
anything larger it quickly becomes worthwhile... and running a
profiler on a small code will make more sense than trying it on
something big so this is a great place to start... On linux oprofile
is great, on Windows you'll have to ask somebody else... like Stack
Overlfow: http://stackoverflow.com/questions/13224322/profiling-rcpp-code-on-os-x

Krzysztof



On Wed, Jul 16, 2014 at 1:15 PM, Steve Bellan <steve.bellan at gmail.com> wrote:
> also, note I just got a slight bump in speed by only doing
>
> NumericMatrix serosO=clone(seros);
>
> once, outside of the loop and by just doing
>
> serosO=seros;
>
> inside the loop so that there was no re-initialization of serosO each time. Now I'm 3.5X instead of 2.5X R-speed for 10^4 numcouples, but I keep seeing people talk about 30X increases and I'm hoping to approach that.
>
> _______________________________________________
> 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



-- 

Krzysztof Sakrejda

Organismic and Evolutionary Biology
University of Massachusetts, Amherst
319 Morrill Science Center South
611 N. Pleasant Street
Amherst, MA 01003

work #: 413-325-6555
email: sakrejda at cns.umass.edu
-----------------------------------------------


More information about the Rcpp-devel mailing list