Skip to content

Instantly share code, notes, and snippets.

@grimbough
Created February 25, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grimbough/30421672a1365840ebf49d8099565870 to your computer and use it in GitHub Desktop.
Save grimbough/30421672a1365840ebf49d8099565870 to your computer and use it in GitHub Desktop.
Timing BigDataAlgorithms::rsvd against base::svd
library(TENxBrainData)
library(ggplot2)
library(tidyr)
tenx <- TENxBrainData()
ncols <- c(1,2,5,10,20,50,100,200,500,1000)
svd <- bda <- numeric(length = length(ncols))
for(i in seq_along(ncols)) {
ncol = ncols[i]
message(ncol)
svd[i] <- system.time( svd1 <- svd(counts(tenx[,1:ncol])) )['elapsed']
message(ncol)
bda[i] <- system.time( svd2 <- BigDataAlgorithms::rsvd(counts(tenx[,1:ncol])) )['elapsed']
}
res <- data.frame(ncols, svd, bda) %>%
tidyr::gather(key = 'algorithm', value = time, -ncols)
ggplot(res, aes(x = ncols,
y = time,
colour = algorithm)) +
geom_line()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment