Skip to content

Instantly share code, notes, and snippets.

@maletor
Created January 18, 2011 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maletor/784711 to your computer and use it in GitHub Desktop.
Save maletor/784711 to your computer and use it in GitHub Desktop.
ruby-1.9.2-p136 :009 > Benchmark.measure do
ruby-1.9.2-p136 :010 > 1000.times do
ruby-1.9.2-p136 :011 > firstline = `head -n1 /Users/eberner/Sites/capstone/README`
ruby-1.9.2-p136 :012?> end
ruby-1.9.2-p136 :013?> end
=> 0.100000 1.020000 3.120000 ( 3.256357)
ruby-1.9.2-p136 :014 > Benchmark.measure do
ruby-1.9.2-p136 :015 > 1000.times do
ruby-1.9.2-p136 :016 > firstline = File.open('/Users/eberner/Sites/capstone/README') {|f| f.readline}
ruby-1.9.2-p136 :017?> end
ruby-1.9.2-p136 :018?> end
=> 0.020000 0.030000 0.050000 ( 0.057493)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment