Skip to content

Instantly share code, notes, and snippets.

@jodell
Created June 22, 2011 21:00
Show Gist options
  • Save jodell/1041184 to your computer and use it in GitHub Desktop.
Save jodell/1041184 to your computer and use it in GitHub Desktop.
expensive function tracing
set_trace_func proc { |event, file, line, id, binding, classname|
#cpu = `ps auxfh | grep #{$$} | grep -v tracer | grep -v grep | awk '{print $3}'`.strip
fid ||= File.open("/tmp/tracer.#{$$}", 'a+')
fid.puts "[%s][%s] %8s %s:%-2d %10s %8s\n" % [Time.now, '', event, file, line, id, classname] if file.match(/srv/) && !file.match(/vendor\/|usr\/local\/lib/)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment