Created
May 15, 2013 02:33
-
-
Save meatballhat/5581272 to your computer and use it in GitHub Desktop.
Crappy benchmark for `IO#each_line` performance. In local tests, I provided a file containing 100 copies of `/usr/share/dict/words`.
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
File.open(ARGV.first).each_line do |line| | |
1 + 1 | |
end | |
out = '' | |
start = Time.now | |
File.open(ARGV.first).each_line do |line| | |
out << line | |
end | |
read_end = Time.now | |
puts out | |
final = Time.now | |
$stderr.puts "Reading: #{read_end - start}" | |
$stderr.puts "Writing: #{final - read_end}" | |
$stderr.puts "Total: #{final - start}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment