Skip to content

Instantly share code, notes, and snippets.

@meatballhat
Created May 15, 2013 02:33
Show Gist options
  • Save meatballhat/5581272 to your computer and use it in GitHub Desktop.
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`.
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