Class: QaServer::PerformanceCalculatorService

Inherits:
Object
  • Object
show all
Includes:
PerformanceHistoryDataKeys
Defined in:
app/services/qa_server/performance_calculator_service.rb

Constant Summary

Constants included from PerformanceHistoryDataKeys

QaServer::PerformanceHistoryDataKeys::ALL_AUTH, QaServer::PerformanceHistoryDataKeys::AVG_FULL, QaServer::PerformanceHistoryDataKeys::AVG_LOAD, QaServer::PerformanceHistoryDataKeys::AVG_NORM, QaServer::PerformanceHistoryDataKeys::BY_DAY, QaServer::PerformanceHistoryDataKeys::BY_HOUR, QaServer::PerformanceHistoryDataKeys::BY_MONTH, QaServer::PerformanceHistoryDataKeys::FOR_DATATABLE, QaServer::PerformanceHistoryDataKeys::FOR_DAY, QaServer::PerformanceHistoryDataKeys::FOR_MONTH, QaServer::PerformanceHistoryDataKeys::FOR_YEAR, QaServer::PerformanceHistoryDataKeys::HIGH_FULL, QaServer::PerformanceHistoryDataKeys::HIGH_LOAD, QaServer::PerformanceHistoryDataKeys::HIGH_NORM, QaServer::PerformanceHistoryDataKeys::LOW_FULL, QaServer::PerformanceHistoryDataKeys::LOW_LOAD, QaServer::PerformanceHistoryDataKeys::LOW_NORM, QaServer::PerformanceHistoryDataKeys::STATS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ PerformanceCalculatorService

Returns a new instance of PerformanceCalculatorService.

Parameters:

  • records (Array <Qa::PerformanceHistory>) —

    set of records used to calculate the statistics



12
13
14
15
# File 'app/services/qa_server/performance_calculator_service.rb', line 12

def initialize(records)
  @records = records
  @stats = {}
end

Instance Attribute Details

#records ⇒ Object (readonly)

Returns the value of attribute records.



8
9
10
# File 'app/services/qa_server/performance_calculator_service.rb', line 8

def records
  @records
end

#stats ⇒ Object (readonly)

Returns the value of attribute stats.



9
10
11
# File 'app/services/qa_server/performance_calculator_service.rb', line 9

def stats
  @stats
end

Instance Method Details

#calculate_stats(avg: false, low: false, high: false, load: true, norm: true, full: true) ⇒ Hash

Calculate performance statistics for a set of PerformanceHistory records. Min is at the 10th percentile. Max is at the 90th percentile. { load_avg_ms: 12.3, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, load_min_ms: 12.3, normalization_min_ms: 4.2, full_request_min_ms: 16.5, load_max_ms: 12.3, normalization_max_ms: 4.2, full_request_max_ms: 16.5 }

Returns:

  • (Hash) —

    hash of the statistics



23
24
25
26
27
28
# File 'app/services/qa_server/performance_calculator_service.rb', line 23

def calculate_stats(avg: false, low: false, high: false, load: true, norm: true, full: true) # rubocop:disable Metrics/ParameterLists
  calculate_load_stats(avg, low, high) if load
  calculate_norm_stats(avg, low, high) if norm
  calculate_full_stats(avg, low, high) if full
  stats
end