Module: BWAPI::Performance

Included in:
Client
Defined in:
lib/bwapi/performance.rb

Overview

Performance module

Instance Method Summary collapse

Instance Method Details

#average_response_timeObject



7
8
9
10
11
# File 'lib/bwapi/performance.rb', line 7

def average_response_time
  averages = []
  performance.each_key { |key| averages << Allotment.results[key].average }
  averages.average
end

#average_response_time_breakdownObject



13
14
15
16
17
18
19
# File 'lib/bwapi/performance.rb', line 13

def average_response_time_breakdown
  results = []
  performance.each do |key, value|
    results << Hashie::Mash.new(path: key, average: Allotment.results[key].average, count: value.size)
  end
  results
end

#fastest_responseObject



21
22
23
# File 'lib/bwapi/performance.rb', line 21

def fastest_response
  average_response_time_breakdown.sort_by { |result| result[:average] }.first
end

#response_pathsObject



25
26
27
# File 'lib/bwapi/performance.rb', line 25

def response_paths
  performance.keys
end

#slowest_responseObject



29
30
31
# File 'lib/bwapi/performance.rb', line 29

def slowest_response
  average_response_time_breakdown.sort_by { |result| result[:average] }.reverse.first
end

#total_responsesObject



33
34
35
36
37
# File 'lib/bwapi/performance.rb', line 33

def total_responses
  responses = 0
  performance.each_value { |value| responses += value.size }
  responses
end