【问题标题】:What is the best way to create a script to use with the rails request profiler?创建与 rails 请求分析器一起使用的脚本的最佳方法是什么?
【发布时间】:2010-09-13 23:22:11
【问题描述】:

rails scirpt script/performance/request 需要一个会话脚本,生成这个会话脚本的最佳方法是什么?

【问题讨论】:

    标签: ruby-on-rails performance profiling


    【解决方案1】:

    将此代码添加到您的 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文件中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-14
      • 1970-01-01
      • 2012-04-01
      • 1970-01-01
      • 2011-08-26
      • 2010-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多