Skip to content

Instantly share code, notes, and snippets.

@rajdeep26
Created June 15, 2016 07:05
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 rajdeep26/32bdba87fe1f14b241a9dbab9ee94f55 to your computer and use it in GitHub Desktop.
Save rajdeep26/32bdba87fe1f14b241a9dbab9ee94f55 to your computer and use it in GitHub Desktop.
Benchmarking ruby's hashing algorithms
SRC = SecureRandom.uuid
Benchmark.bmbm do |bm|
bm.report('MD5') { 100000.times{ Digest::MD5.hexdigest SRC } }
bm.report('SHA1') { 100000.times{ Digest::SHA1.hexdigest SRC } }
bm.report('SHA2') { 100000.times{ Digest::SHA2.hexdigest SRC } }
bm.report('SHA256') { 100000.times{ Digest::SHA256.hexdigest SRC } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment