创建脚本以与Rails Request Profiler一起使用的最佳方法是什么?
时间:2020-03-06 14:52:08 来源:igfitidea点击:
rails scirptscript / performance / request
需要一个会话脚本,生成此会话脚本的最佳方法是什么?
解决方案
将此代码添加到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
然后,我们可以在浏览器中访问多个页面,并将会话脚本写入应用程序根目录中的request_log.txt文件中。