Created
September 3, 2009 23:51
-
-
Save square/180616 to your computer and use it in GitHub Desktop.
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
Rehearsal ---------------------------------------------------- | |
normal SHA-1 3.130000 1.040000 4.170000 ( 4.180956) | |
shell SHA-1 0.010000 0.040000 3.990000 ( 4.042143) | |
file-based SHA-1 3.010000 0.510000 3.520000 ( 3.534705) | |
------------------------------------------ total: 11.680000sec | |
user system total real | |
normal SHA-1 3.140000 1.040000 4.180000 ( 4.196356) | |
shell SHA-1 0.010000 0.040000 3.990000 ( 4.007471) | |
file-based SHA-1 3.010000 0.520000 3.530000 ( 3.544147) |
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/sha1' | |
name = "big.tar.gz" | |
Benchmark.bmbm do |x| | |
x.report("normal SHA-1") { | |
100.times { File.open(name, 'r') { |file| Digest::SHA1.hexdigest(file.read) } } | |
} | |
x.report("shell SHA-1") { | |
100.times { `openssl sha1 #{name}` } | |
} | |
x.report("file-based SHA-1") { | |
100.times { Digest::SHA1.file(name).hexdigest } | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment