search for: idxs1

Displaying 1 result from an estimated 1 matches for "idxs1".

Did you mean: idx1
2008 Jul 11
1
Suggestion: 20% speed up of which() with two-character mod
...ll. BENCHMARKING: # To measure both in same environment which1 <- base::which; environment(which1) <- globalenv(); # Needed? N <- 1e6; set.seed(0xbeef); x <- sample(c(TRUE, FALSE), size=N, replace=TRUE); names(x) <- seq_along(x); B <- 10; t1 <- system.time({ for (bb in 1:B) idxs1 <- which1(x); }); t2 <- system.time({ for (bb in 1:B) idxs2 <- which2(x); }); stopifnot(identical(idxs1, idxs2)); print(t1/t2); # Fair benchmarking t2 <- system.time({ for (bb in 1:B) idxs2 <- which2(x); }); t1 <- system.time({ for (bb in 1:B) idxs1 <- which1(x); }); print(t1/t...