Created
May 7, 2019 09:10
-
-
Save madwork/dd26284994d2a681f4c66db28673c36a to your computer and use it in GitHub Desktop.
ruby Digest::* benchmark
This file contains hidden or 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
# gem install benchmark-ips | |
require 'digest/sha1' | |
require 'digest/sha2' | |
require 'benchmark/ips' | |
puts RUBY_DESCRIPTION | |
SRC = File.read '/dev/urandom', 8192 | |
Benchmark.ips do |x| | |
x.report('MD5') { Digest::MD5.hexdigest SRC } | |
x.report('SHA1') { Digest::SHA1.hexdigest SRC } | |
x.report('SHA2') { Digest::SHA2.hexdigest SRC } | |
x.report('SHA256') { Digest::SHA256.hexdigest SRC } | |
end |
This file contains hidden or 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
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