Skip to content

Instantly share code, notes, and snippets.

@dirkschumacher
Last active January 11, 2020 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirkschumacher/cefbd91078ea2572bc4f369f7bf212f5 to your computer and use it in GitHub Desktop.
Save dirkschumacher/cefbd91078ea2572bc4f369f7bf212f5 to your computer and use it in GitHub Desktop.
library(blake3)
library(digest)
input <- charToRaw(paste0(sample(LETTERS, 1e6, replace = TRUE), collapse = ""))
microbenchmark::microbenchmark(
  blake3 = sodium::bin2hex(blake3_hash_raw(input)),
  sha1 = digest(input, "sha1", serialize = FALSE),
  md5 = digest(input, "md5", serialize = FALSE),
  sha256 = digest(input, "sha256", serialize = FALSE),
  osha1 = openssl::sha1(input),
  omd5 = openssl::md5(input)
)
#> Unit: microseconds
#>    expr      min       lq      mean    median       uq       max neval
#>  blake3  408.787  453.128  772.7817  498.3765  692.510 13116.518   100
#>    sha1 2959.160 3021.551 3413.5665 3220.8030 3605.965  5661.708   100
#>     md5 2901.487 2938.036 3198.8274 3044.0600 3273.970  4854.796   100
#>  sha256 7410.336 7760.696 8530.5532 8264.7450 9062.605 11774.196   100
#>   osha1 1191.946 1259.450 1976.4855 1321.8015 1762.416 44240.834   100
#>    omd5 1653.341 1716.120 1875.0597 1771.3005 1930.062  2888.618   100

Created on 2020-01-11 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment