Open krlmlr opened 5 months ago
Slower than match() by 50%?
match()
n <- 1E6 m <- 1E3 vs <- seq(n) index <- seq(m) value <- list(rev = as.list(rev(index)), nchar = as.list(nchar(index))) bench::mark( "Rmatch" = { value_nw2 <- lapply(value, function(x) { unname(x[match(seq_along(vs), index)]) }) }, "vec_match" = { value_nw2 <- lapply(value, function(x) { unname(x[vctrs::vec_match(seq_along(vs), index)]) }) } ) #> # A tibble: 2 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> #> 1 Rmatch 13.6ms 14.1ms 69.7 34.6MB 279. #> 2 vec_match 27.3ms 28.1ms 34.1 38.2MB 102.
Created on 2024-04-09 with reprex v2.1.0
Downstream: https://github.com/igraph/rigraph/issues/1327#issuecomment-2045129859
Slower than
match()
by 50%?Created on 2024-04-09 with reprex v2.1.0
Downstream: https://github.com/igraph/rigraph/issues/1327#issuecomment-2045129859