Created
July 20, 2015 07:17
-
-
Save snipsnipsnip/8130bb61a013ec795bce to your computer and use it in GitHub Desktop.
stdlib-digest-openssldigest-benchmark.rb
This file contains 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
require 'benchmark' | |
require 'digest' | |
require 'openssl' | |
lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.' * 1000 | |
n = 10000 | |
Benchmark.bmbm do |b| | |
b.report('digest') { n.times { Digest::SHA1.digest(lorem) } } | |
b.report('openssl') { n.times { OpenSSL::Digest::SHA1.new.digest(lorem) } } | |
end | |
__END__ | |
user system total real | |
digest 6.364000 0.000000 6.364000 ( 6.404366) | |
openssl 6.459000 0.000000 6.459000 ( 6.472371) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment