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_ACTIONS, QaServer::PerformanceHistoryDataKeys::ALL_AUTH, QaServer::PerformanceHistoryDataKeys::AVG_ACTN, QaServer::PerformanceHistoryDataKeys::AVG_FULL, QaServer::PerformanceHistoryDataKeys::AVG_GRPH, QaServer::PerformanceHistoryDataKeys::AVG_LOAD, QaServer::PerformanceHistoryDataKeys::AVG_NORM, QaServer::PerformanceHistoryDataKeys::AVG_RETR, QaServer::PerformanceHistoryDataKeys::BPMS_GRPH, QaServer::PerformanceHistoryDataKeys::BPMS_NORM, QaServer::PerformanceHistoryDataKeys::BPMS_RETR, QaServer::PerformanceHistoryDataKeys::BY_DAY, QaServer::PerformanceHistoryDataKeys::BY_HOUR, QaServer::PerformanceHistoryDataKeys::BY_MONTH, QaServer::PerformanceHistoryDataKeys::FETCH, QaServer::PerformanceHistoryDataKeys::FOR_DATATABLE, QaServer::PerformanceHistoryDataKeys::FOR_DAY, QaServer::PerformanceHistoryDataKeys::FOR_MONTH, QaServer::PerformanceHistoryDataKeys::FOR_YEAR, QaServer::PerformanceHistoryDataKeys::HIGH_ACTN, QaServer::PerformanceHistoryDataKeys::HIGH_FULL, QaServer::PerformanceHistoryDataKeys::HIGH_GRPH, QaServer::PerformanceHistoryDataKeys::HIGH_LOAD, QaServer::PerformanceHistoryDataKeys::HIGH_NORM, QaServer::PerformanceHistoryDataKeys::HIGH_RETR, QaServer::PerformanceHistoryDataKeys::LOW_ACTN, QaServer::PerformanceHistoryDataKeys::LOW_FULL, QaServer::PerformanceHistoryDataKeys::LOW_GRPH, QaServer::PerformanceHistoryDataKeys::LOW_LOAD, QaServer::PerformanceHistoryDataKeys::LOW_NORM, QaServer::PerformanceHistoryDataKeys::LOW_RETR, QaServer::PerformanceHistoryDataKeys::MSPB_GRPH, QaServer::PerformanceHistoryDataKeys::MSPB_NORM, QaServer::PerformanceHistoryDataKeys::MSPB_RETR, QaServer::PerformanceHistoryDataKeys::SEARCH, QaServer::PerformanceHistoryDataKeys::SRC_BYTES, QaServer::PerformanceHistoryDataKeys::STATS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records, action: nil) ⇒ PerformanceCalculatorService

Returns a new instance of PerformanceCalculatorService.

Parameters:

  • records (Array <Qa::PerformanceHistory>)

    set of records used to calculate the statistics



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

def initialize(records, action: nil)
  @records = records
  @action = [:search, :fetch].include?(action) ? action : nil
  @stats = {}
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



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

def action
  @action
end

#recordsObject (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

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end

Instance Method Details

#calculate_average_statsHash

Calculate performance statistics including averages only.

Examples:

{ retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5 }

Returns:

  • (Hash)

    hash of the statistics



35
36
37
38
39
40
41
# File 'app/services/qa_server/performance_calculator_service.rb', line 35

def calculate_average_stats
  calculate_load_stats(true, false, false) # used for backward compatibility only
  calculate_retrieve_stats(true, false, false)
  calculate_graph_load_stats(true, false, false)
  calculate_normalization_stats(true, false, false)
  stats
end

#calculate_stats_with_percentilesHash

Calculate performance statistics with percentiles. Min is at the 10th percentile. Max is at the 90th percentile.

Examples:

{ retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5,
  retrieve_10th_ms: 12.3, graph_load_10th_ms: 12.3, normalization_10th_ms: 4.2, full_request_10th_ms: 16.5,
  retrieve_90th_ms: 12.3, graph_load_90th_ms: 12.3, normalization_90th_ms: 4.2, full_request_90th_ms: 16.5 }

Returns:

  • (Hash)

    hash of the statistics



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

def calculate_stats_with_percentiles
  calculate_retrieve_stats(true, true, true)
  calculate_graph_load_stats(true, true, true)
  calculate_normalization_stats(true, true, true)
  calculate_action_stats(true, true, true)
  stats
end