Class: RailsPerformance::Reports::ThroughputReport

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

Instance Attribute Summary

Attributes inherited from BaseReport

#db, #group, #sort, #title

Instance Method Summary collapse

Methods inherited from BaseReport

#collect, #initialize

Constructor Details

This class inherits a constructor from RailsPerformance::Reports::BaseReport

Instance Method Details

#dataObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rails_performance/reports/throughput_report.rb', line 9

def data
  all     = {}
  stop    = Time.at(60 * (Time.now.to_i / 60))
  current = stop - RailsPerformance.duration
  @data   = []
  offset  = Time.current.utc_offset

  # puts "current: #{current}"
  # puts "stop: #{stop}"

  # read current values
  db.group_by(group).each do |(k, v)|
    all[k] = v.count
  end

  # add blank columns
  while current <= stop
    views = all[current.strftime(RailsPerformance::FORMAT)] || 0
    @data << [(current.to_i + offset) * 1000, views.to_i]
    current += 1.minute
  end

  # sort by time
  @data.sort!
end

#set_defaultsObject



5
6
7
# File 'lib/rails_performance/reports/throughput_report.rb', line 5

def set_defaults
  @group ||= :datetime
end