Class: RailsPerformance::RequestsReport

Inherits:
BaseReport
  • Object
show all
Defined in:
lib/rails_performance/requests_report.rb

Instance Attribute Summary

Attributes inherited from BaseReport

#db, #group, #sort

Instance Method Summary collapse

Methods inherited from BaseReport

#collect, #initialize

Constructor Details

This class inherits a constructor from RailsPerformance::BaseReport

Instance Method Details

#dataObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails_performance/requests_report.rb', line 7

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

#set_defaultsObject



3
4
5
# File 'lib/rails_performance/requests_report.rb', line 3

def set_defaults
  @sort ||= :count
end