Last active
October 21, 2024 14:44
-
-
Save mkroman/f9b1673721bcdeb8e6daf25129d87190 to your computer and use it in GitHub Desktop.
Revisions
-
mkroman revised this gist
Mar 17, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ file.unlink # mk@… ~/Projects/Sandbox % ruby digest-sha256-file-vs-system-sha256sum.rb # Warming up -------------------------------------- # Digest::SHA256.file 72.000 i/100ms # `sha256sum` 44.000 i/100ms # Calculating ------------------------------------- # Digest::SHA256.file 738.569 (± 2.0%) i/s - 3.744k in 5.071405s -
mkroman revised this gist
Mar 17, 2019 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,11 +21,11 @@ file.close file.unlink # mk@… ~/Projects/Sandbox % ruby digest-sha256-file-vs-system-sha256sum.rb # Warming up -------------------------------------- # Digest::SHA256.file 72.000 i/100ms # `sha256sum` 44.000 i/100ms # Calculating ------------------------------------- # Digest::SHA256.file 738.569 (± 2.0%) i/s - 3.744k in 5.071405s # `sha256sum` 457.612 (± 7.9%) i/s - 2.288k in 5.034049s # ruby digest-sha256-file-vs-system-sha256sum.rb 10,21s user 4,17s system 99% cpu 14,393 total -
mkroman renamed this gist
Mar 17, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mkroman created this gist
Mar 8, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ mk@… ~/Projects/Sandbox % cat digest-sha256-file-vs-system-sha256sum.rb #!/usr/bin/env ruby require 'tempfile' require 'digest/sha2' require 'benchmark/ips' file = Tempfile.new 'testfile' file.write 'a' * 1024 * 1024 * 2 Benchmark.ips do |x| x.report 'Digest::SHA256.file' do Digest::SHA256.file(file.path).hexdigest end x.report '`sha256sum`' do `sha256sum #{file.path}`.strip end end file.close file.unlink mk@… ~/Projects/Sandbox % ruby digest-sha256-file-vs-system-sha256sum.rb Warming up -------------------------------------- Digest::SHA256.file 72.000 i/100ms `sha256sum` 44.000 i/100ms Calculating ------------------------------------- Digest::SHA256.file 738.569 (± 2.0%) i/s - 3.744k in 5.071405s `sha256sum` 457.612 (± 7.9%) i/s - 2.288k in 5.034049s ruby digest-sha256-file-vs-system-sha256sum.rb 10,21s user 4,17s system 99% cpu 14,393 total