Created
November 15, 2010 23:32
-
-
Save Phrogz/701176 to your computer and use it in GitHub Desktop.
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
file = ARGV[0] | |
2.times do | |
lines, bytes = 0,0 | |
start = Time.now | |
contents = File.open(file){ |f| f.read } | |
contents.scan(/.+/) do |line| | |
lines += 1 | |
bytes += line.size | |
end | |
elapsed = Time.now-start | |
mb = bytes.to_f / 2**20 | |
puts "File.open(...) read %d lines & %0.1fMB in %0.3fs (%d lines/sec, %0.1fMB/sec)" % [ | |
lines, mb, elapsed, lines/elapsed, mb/elapsed | |
] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment