Class: Symian::PerformanceAnalyzer
- Inherits:
-
Object
- Object
- Symian::PerformanceAnalyzer
- Defined in:
- lib/symian/performance_analyzer.rb
Instance Method Summary collapse
- #calculate_kpis(trace) ⇒ Object
-
#initialize(config) ⇒ PerformanceAnalyzer
constructor
A new instance of PerformanceAnalyzer.
Constructor Details
#initialize(config) ⇒ PerformanceAnalyzer
Returns a new instance of PerformanceAnalyzer.
10 11 12 |
# File 'lib/symian/performance_analyzer.rb', line 10 def initialize(config) @warmup_threshold = config.start_time + config.warmup_duration end |
Instance Method Details
#calculate_kpis(trace) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/symian/performance_analyzer.rb', line 14 def calculate_kpis(trace) raise ArgumentError, 'Argument must be a TraceCollector' unless TraceCollector === trace kpis = {} # these metrics are considered as kpis kpis[:all_incidents] = trace.incidents kpis[:incidents_considered] = 0 kpis[:closed_incidents] = 0 kpis[:mean_ttr] = 0 kpis[:max_ttr] = 0 kpis[:mean_waiting_time] = 0 max_ttr = 0 ttr_sum = 0 wt_sum = 0 trace.with_incidents do |i| next if @warmup_threshold and i.arrival_time < @warmup_threshold kpis[:incidents_considered] += 1 if i.closed? kpis[:closed_incidents] += 1 ttr = i.total_work_time ttr_sum += ttr wt_sum += i.total_queue_time max_ttr = ttr if ttr > max_ttr end end kpis[:max_ttr] = max_ttr if kpis[:closed_incidents] == 0 kpis[:mean_ttr] = Float::MAX kpis[:mean_waiting_time] = Float::MAX else kpis[:mean_ttr] = ttr_sum / kpis[:closed_incidents] kpis[:mean_waiting_time] = wt_sum / kpis[:closed_incidents] end # return kpis kpis end |