Created
January 13, 2026 19:10
-
-
Save abikoushi/595ea14e90c733a628fa8fd52802ebc1 to your computer and use it in GitHub Desktop.
Try multi-threads `roll` package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(roll) | |
| library(RcppParallel) | |
| RcppParallel::defaultNumThreads() | |
| x <- rnorm(1e8) | |
| setThreadOptions(numThreads = 1L) | |
| t1 <- system.time({ | |
| roll_mean(x, 1000) | |
| }) | |
| setThreadOptions(numThreads = 8L) | |
| t2 <- system.time({ | |
| roll_mean(x, 1000) | |
| }) | |
| t1; t2 | |
| # user system elapsed | |
| # 0.286 0.037 0.328 | |
| # user system elapsed | |
| # 0.283 0.001 0.282 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment