Skip to content

Instantly share code, notes, and snippets.

@zetter zetter/Slow queries
Created Feb 8, 2011

Embed
What would you like to do?
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
You can’t perform that action at this time.