Last active
March 27, 2022 00:49
-
-
Save traversc/f357c5f1a4b0368649849dd3d1f49d14 to your computer and use it in GitHub Desktop.
Benching stringi with and without altrep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stringi) # devtools::install_github("traversc/stringi") | |
library(tictoc) | |
enwik8 <- readLines("~/Downloads/enwik8", warn = F) | |
search <- c("Wikipedia", "^.") | |
replace <- c("Encyclopedia", "") | |
tic("WITHOUT alt rep") | |
stri_use_alt_rep(FALSE); result <- stri_replace_all_regex(enwik8, search, replace, vectorize_all = F) | |
toc() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stringi) # devtools::install_github("traversc/stringi") | |
library(tictoc) | |
enwik8 <- readLines("~/Downloads/enwik8", warn = F) | |
search <- c("Wikipedia", "^.") | |
replace <- c("Encyclopedia", "") | |
tic("WITH alt rep") | |
stri_use_alt_rep(TRUE); result <- stri_replace_all_regex(enwik8, search, replace, vectorize_all = F) | |
toc() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment