Why my Rcpp code is not much faster?

牧云@^-^@ 提交于 2019-12-04 12:10:07

Okay, 70% of the times is used for ordering the list (x2.sort(std::greater<double>());). I think this is because lists are not contiguous data (as compared to a vector).

So, removing this line and using create_groups2(sort(x_big, decreasing = TRUE), 34) improve performance by 3, which makes the Rcpp version 9-11.5 times faster than the R version for x_big of size 1e4-1e5.

This is better, but I was still expecting much more. I think my algorithm is still quadratic in the size of the input, this is why I can't get dramatic improvements.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!