Sha256: c47a46b3be53db2a21b32ebe5aea52220201dfe89bf1661e5dcc69a2158a01db

Contents?: true

Size: 953 Bytes

Versions: 5

Compression:

Stored size: 953 Bytes

Contents

module RailsPerformance
  module Reports
    class RequestsReport < BaseReport
      def set_defaults
        @sort ||= :count
      end

      def data
        collect do |k, v|
          durations     = v.collect{|e| e["duration"]}.compact
          view_runtimes = v.collect{|e| e["view_runtime"]}.compact
          db_runtimes   = v.collect{|e| e["db_runtime"]}.compact
          {
            group:                k,
            count:                v.size,
            duration_average:     durations.sum.to_f / durations.size,
            view_runtime_average: view_runtimes.sum.to_f / view_runtimes.size,
            db_runtime_average:   db_runtimes.sum.to_f / db_runtimes.size,
            duration_slowest:     durations.max,
            view_runtime_slowest: view_runtimes.max,
            db_runtime_slowest:   db_runtimes.max,
          }
        end.sort{|a, b| b[sort] <=> a[sort]}
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_performance-0.0.1.10 lib/rails_performance/reports/requests_report.rb
rails_performance-0.0.1.9 lib/rails_performance/reports/requests_report.rb
rails_performance-0.0.1.8 lib/rails_performance/reports/requests_report.rb
rails_performance-0.0.1.6 lib/rails_performance/reports/requests_report.rb
rails_performance-0.0.1.5 lib/rails_performance/reports/requests_report.rb