d = tibble(
x = runif(10000),
y=runif(10000)
)
(b = bench::mark(
d[d$x > 0.5, ],
d[which(d$x > 0.5), ],
subset(d, x > 0.5),
filter(d, x > 0.5)
))# A tibble: 4 × 6
expression min median `itr/sec` mem_alloc `gc/sec`
<bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
1 d[d$x > 0.5, ] 102.92µs 116.71µs 7998. 252.16KB 21.7
2 d[which(d$x > 0.5), ] 88.08µs 99µs 9353. 271.9KB 51.1
3 subset(d, x > 0.5) 145.17µs 160.38µs 5938. 288.2KB 35.0
4 filter(d, x > 0.5) 2.05ms 2.15ms 454. 2.01MB 12.7