Skip to content

Instantly share code, notes, and snippets.

@bbrowning
Created December 8, 2014 15:43
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 bbrowning/24cfdba60ce1cdc887cc to your computer and use it in GitHub Desktop.
Save bbrowning/24cfdba60ce1cdc887cc to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'openssl'
NUM_THREADS = 40
NUM_DIGESTS = 100_000
puts Benchmark.measure {
threads = NUM_THREADS.times.map do
Thread.new do
secret = 'foobarbaz'
data = 'bingobongo'*100
NUM_DIGESTS.times do
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, data)
end
end
end
threads.each(&:join)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment