Sha256: 35c9d1e1ce38f9c89f9d1a4d6264733979499778bd0d3971a5638c92a02001b8

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

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,
            p50_duration: RailsPerformance::Utils.percentile(durations, 50),
            p95_duration: RailsPerformance::Utils.percentile(durations, 95),
            p99_duration: RailsPerformance::Utils.percentile(durations, 99)
          }
        end.sort_by { |e| -e[sort].to_f } # to_f because could ne NaN or nil
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_performance-1.4.1 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.1.alpha1 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.0 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.0.alpha5 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.0.alpha4 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.0.alpha3 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.0.alpha2 lib/rails_performance/reports/requests_report.rb
rails_performance-1.4.0.alpha1 lib/rails_performance/reports/requests_report.rb
rails_performance-1.3.3 lib/rails_performance/reports/requests_report.rb