Last active
November 13, 2018 22:16
-
-
Save grimbough/bc26824e35a07325c4244bff20b978fb to your computer and use it in GitHub Desktop.
Testing performance of H5Sselect_index in the rhdf5 package
This file contains 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(rhdf5) | |
hslab_bm <- function(m = 10000, n = 10000) { | |
## TENxBrainData | |
fid <- H5Fopen('/media/Storage/Work/ExperimentHub/1040') | |
did <- H5Dopen(h5loc = fid, 'counts') | |
sid <- H5Dget_space(did) | |
## select first 100 rows and a random (ordered) sample of columns | |
index <- list(1:100, | |
sort(sample(x = 1:m, size = n, replace = FALSE))) | |
size <- H5Sselect_index(h5space = sid, index = index) | |
## tidy up | |
H5Sclose(sid) | |
H5Dclose(did) | |
H5Fclose(fid) | |
} | |
hslab2_bm <- function(m = 10000, n = 10000) { | |
fid <- H5Fopen('/media/Storage/Work/ExperimentHub/1040') | |
did <- H5Dopen(h5loc = fid, 'counts') | |
sid <- H5Dget_space(did) | |
x <- sort(sample(x = 1:m, size = n, replace = FALSE)) | |
x2 <- x %/% 100 | |
for(i in unique(x2)) { | |
index <- list(1:100, | |
x[x2 == i]) | |
size = H5Sselect_index(h5space = sid, index = index) | |
} | |
## tidy up | |
H5Sclose(sid) | |
H5Dclose(did) | |
H5Fclose(fid) | |
} | |
microbenchmark::microbenchmark( | |
hslab_bm(m = 10000, n = 10000), | |
hslab_bm(m = 15000, n = 10000), | |
hslab_bm(m = 20000, n = 10000), | |
hslab2_bm(m = 10000, n = 10000), | |
hslab2_bm(m = 15000, n = 10000), | |
hslab2_bm(m = 20000, n = 10000), | |
times = 5 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment