# NOT RUN {
pts <- icd:::random_unordered_patients(1e7)
u <- unique.default(pts$code)
# this shows that stringr (which uses stringi) sort takes 50% longer than
# built-in R sort.
microbenchmark::microbenchmark(sort(u), str_sort(u))
# this shows that \code{factor_} is about 50% faster than \code{factor} for
# big vectors of strings
# without sorting is much faster:
microbenchmark::microbenchmark(factor(pts$code),
# factor_(pts$code),
factor_nosort(pts$code),
times = 25
)
# }
Run the code above in your browser using DataLab