2 ms·
Huh. Turns out I'm wrong. I ran benchmarking on a 1.8M row dataset of SF crime data w/ 100 replications. Running grepl() via: benchmark(df %>% sample_frac(
by minimaxir 11y ago
Huh. Turns out I'm wrong. I ran benchmarking on a 1.8M row dataset of SF crime data w/ 100 replications.
Running grepl() via:
benchmark(df %>% sample_frac() %>% filter(grepl("ARREST", Resolution)))
completed in 257.58 seconds.
Running str_detect() via:
benchmark(df %>% sample_frac() %>% filter(str_detect(Resolution, "ARREST")))
completed in 248.917 seconds.
Overall, str_detect() is faster by 3%. The stringr packages has more surprises than I thought!