n <- 100000
cols <- 150
data_mat <- matrix(rnorm(n * cols, mean = 5), ncol = cols)
data <- as.data.frame(data_mat)
bench::mark(
means <- colMeans(data_mat),
means <- colMeans(data),
check = F
)
# A tibble: 2 × 6
expression min median `itr/sec` mem_alloc `gc/sec`
<bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
1 means <- colMeans(data_mat) 437ms 437ms 2.29 25.4KB 0
2 means <- colMeans(data) 456ms 458ms 2.18 114.5MB 2.18