Skip to content

Instantly share code, notes, and snippets.

@zetter
Created February 8, 2011 09:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zetter/816164 to your computer and use it in GitHub Desktop.
Save zetter/816164 to your computer and use it in GitHub Desktop.
Find the slowest queries lines in a rails development log
file=''
slow = []
File.readlines(file).each do |line|
if line =~ /Load\ \(([\d\.]*)ms\)/
time = $1.to_f
if time >= 500.0
slow << [time, line]
end
end
end
puts slow.length
slow = slow.sort()
myfile = File.new("slowest.txt", "w+")
puts slow.length
slow.each {|line| myfile.puts("#{line[0]} - #{line[1]}")}
myfile.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment