Skip to content

Instantly share code, notes, and snippets.

@abevoelker
Last active December 30, 2015 12:59
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 abevoelker/7833221 to your computer and use it in GitHub Desktop.
Save abevoelker/7833221 to your computer and use it in GitHub Desktop.
Hacky script to convert a Rails log file to timestamp-render time .tsv
IN = '/tmp/production.log'
OUT = '/tmp/render_time.tsv'
render_vals = File.read(IN).split("\n\n").map do |lines|
# render time
m = lines.match(/^Completed in (\d+)ms/)
next unless m
render_time = m.captures[0].to_i
# action and timestamp
m = lines.match(/^Processing (\S*) \(for \S* at ([^)]*)\)/)
next unless m
action, timestamp = m.captures[0], m.captures[1]
[action, timestamp, render_time]
end.compact
File.open(OUT, "w") do |f|
f.write(render_vals.map{|tuple| tuple.join("\t")}.join("\n"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment