Running my first test from #52 (on a slower CPU) brings dqsample.int closer to sample.int for small sets while not compromising performance for larger ones:
library(dqrng)
m <- 1e6
n <- 1e4
prob <- dqrunif(m)
bm <- bench::mark(sample.int(m, n, replace = TRUE, prob = prob),
dqsample.int(m, n, replace = TRUE, prob = prob),
check = FALSE)
bm[, 1:4]
#> # A tibble: 2 × 4
#> expression min median `itr/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl>
#> 1 sample.int(m, n, replace = TRUE, prob = prob) 13.24ms 13.95ms 70.8
#> 2 dqsample.int(m, n, replace = TRUE, prob = prob) 2.49ms 2.54ms 388.
n <- 1e4
m <- 1e1
prob <- dqrunif(m)
bm <- bench::mark(sample.int(m, n, replace = TRUE, prob = prob),
dqsample.int(m, n, replace = TRUE, prob = prob),
check = FALSE)
bm[, 1:4]
#> # A tibble: 2 × 4
#> expression min median `itr/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl>
#> 1 sample.int(m, n, replace = TRUE, prob = prob) 227µs 254µs 3724.
#> 2 dqsample.int(m, n, replace = TRUE, prob = prob) 299µs 336µs 2709.
fixes #52
Running my first test from #52 (on a slower CPU) brings
dqsample.int
closer tosample.int
for small sets while not compromising performance for larger ones:Created on 2023-08-18 with reprex v2.0.2