创建与 rails 请求分析器一起使用的脚本的最佳方法是什么?

Lau*_*ung 5 performance profiling ruby-on-rails

rails scirptscript/performance/request需要会话脚本,生成此会话脚本的最佳方法是什么?

Lau*_*ung 5

将此代码添加到您的 application.rb 文件中

before_filter :benchmark_log

  def benchmark_log
   File.open("request_log.txt","a") do |f|
      f.puts request.method.to_s + " '" + request.request_uri + "', " + params.except(:action).except(:controller).inspect.gsub(/(^\{|\}$)/,"")
    end
  end
Run Code Online (Sandbox Code Playgroud)

然后你可以在浏览器中访问多个页面,会话脚本会被写入到你的应用程序根目录下的 request_log.txt 文件中