Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ruby Digest::* benchmark
# gem install benchmark-ips
require 'digest/sha1'
require 'digest/sha2'
require 'benchmark/ips'
SRC = '/dev/urandom', 8192
Benchmark.ips do |x|'MD5') { Digest::MD5.hexdigest SRC }'SHA1') { Digest::SHA1.hexdigest SRC }'SHA2') { Digest::SHA2.hexdigest SRC }'SHA256') { Digest::SHA256.hexdigest SRC }
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
Warming up --------------------------------------
MD5 7.331k i/100ms
SHA1 8.444k i/100ms
SHA2 3.990k i/100ms
SHA256 3.877k i/100ms
Calculating -------------------------------------
MD5 67.405k (± 5.0%) i/s - 337.226k in 5.015780s
SHA1 82.200k (± 4.8%) i/s - 413.756k in 5.045244s
SHA2 40.337k (± 4.5%) i/s - 203.490k in 5.054968s
SHA256 40.364k (± 4.7%) i/s - 201.604k in 5.006960s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment