Class: Perfm::SidekiqGvlMetric
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Perfm::SidekiqGvlMetric
- Defined in:
- app/models/perfm/sidekiq_gvl_metric.rb
Class Method Summary collapse
Class Method Details
.calculate_queue_io_percentage(queue_name, start_time: nil, end_time: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/perfm/sidekiq_gvl_metric.rb', line 9 def self.calculate_queue_io_percentage(queue_name, start_time: nil, end_time: nil) scope = where(queue: queue_name) scope = scope.within_time_range(start_time, end_time) if start_time && end_time total_run_ms = scope.sum(:run_ms) total_idle_ms = scope.sum(:idle_ms) total_time = total_run_ms + total_idle_ms return 0.0 if total_time == 0 ((total_idle_ms.to_f / total_time) * 100.0).round(2) end |