Created
January 28, 2011 22:29
-
-
Save jonforums/801130 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
puts 'Press a key to begin...'; gets | |
n = 3 | |
fname = File.expand_path(File.join(File.dirname(__FILE__), '..', 'input/lesmiserables.txt')) | |
Benchmark.bmbm do |bm| | |
bm.report 'Big file each_line:' do | |
n.times do | |
count = 0 | |
File.open(fname, 'r').each_line do |line| | |
#count += 1 | |
end | |
end | |
end | |
end |
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
C:\Users\Jon\Documents\RubyDev\measurements-git\workloads>ruby -rbenchmark -v file_lines.rb | |
ruby 1.9.3dev (2011-01-29 trunk 30716) [i386-mingw32] | |
Press a key to begin... | |
Rehearsal ------------------------------------------------------- | |
Big file each_line: 1.872000 0.016000 1.888000 ( 1.906109) | |
---------------------------------------------- total: 1.888000sec | |
user system total real | |
Big file each_line: 1.903000 0.000000 1.903000 ( 1.905109) | |
C:\Users\Jon\Documents\RubyDev\measurements-git\workloads>ruby -rbenchmark -v file_lines.rb | |
ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32] | |
Press a key to begin... | |
Rehearsal ------------------------------------------------------- | |
Big file each_line: 0.234000 0.015000 0.249000 ( 0.237014) | |
---------------------------------------------- total: 0.249000sec | |
user system total real | |
Big file each_line: 0.172000 0.063000 0.235000 ( 0.235014) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment