Created
October 27, 2014 13:26
-
-
Save pd/85bf4eb242faa505e170 to your computer and use it in GitHub Desktop.
UUID v5 vs SHA1 hexdigest
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
require 'json-schema' | |
require 'digest/sha1' | |
require 'benchmark' | |
N = 5000 | |
SCHEMAS = Dir['test/schemas/*.json'].map { |f| File.read(f) } | |
Benchmark.bmbm do |x| | |
x.report('v5') do | |
N.times do | |
SCHEMAS.each { |schema| JSON::Util::UUID.create_sha1(schema, JSON::Util::UUID::Nil).to_s } | |
end | |
end | |
x.report('SHA1') do | |
N.times do | |
SCHEMAS.each { |schema| Digest::SHA1.hexdigest(schema) } | |
end | |
end | |
end | |
__END__ | |
~/sauce/rb/json-schema [chruby:2.1.1] (master δ) » ruby bench.rb | |
Rehearsal ---------------------------------------- | |
v5 0.970000 0.000000 0.970000 ( 0.971467) | |
SHA1 0.150000 0.000000 0.150000 ( 0.144231) | |
------------------------------- total: 1.120000sec | |
user system total real | |
v5 0.970000 0.000000 0.970000 ( 0.970403) | |
SHA1 0.140000 0.000000 0.140000 ( 0.138115) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment