I canβt even say which is better, so the challenge of time will follow. Here's mine:
pmfoo<-10 curtri <- ceiling(sqrt(pmfoo*2 + 0.25) - 0.5) pmbar<-integer() for(j in 1:(curtri)) pmbar<-c(pmbar,rep( (-1)^(j-1),j)) pmbar*1:pmfoo [1] 1 -2 -3 4 5 6 -7 -8 -9 -10
Here are the time tests for the "best view" functions (biased view :-)):
Rgames> x <-1e5 Rgames> microbenchmark(cgw(x),mso(x),willb(x),times=5) Unit: milliseconds expr min lq median uq max cgw(x) 46.61292 47.50237 48.40807 48.42774 52.02789 mso(x) 88.63360 97.72099 97.84286 99.00899 101.57643 willb(x) 281.88658 285.76896 286.92397 290.83628 294.96882 neval 5 5 5
I brought Roland out because he is a major action movie in memory: - (
Run again with the modified mso code:
microbenchmark(cgw(x),mso(x),willb(x),newmso(x),times=5) Unit: milliseconds expr min lq median uq max cgw(x) 51.25860 51.29666 56.21858 58.07190 61.32610 mso(x) 88.08966 89.17924 90.23504 93.28527 95.74666 willb(x) 280.68967 287.53589 287.81086 288.31673 292.60749 newmso(x) 71.53771 72.53193 72.68844 72.99419 79.21480 neval 5 5 5 5
source share