Module: HeapScope::Extrapolation
- Defined in:
- lib/heapscope/extrapolation.rb
Overview
Extrapolates retention rate into a labeled estimate. Never presented as guaranteed.
Class Method Summary collapse
- .objects_per_run(retained_objects:, runs:) ⇒ Object
- .retention_per_hour(retained_bytes:, elapsed_seconds:) ⇒ Object
Class Method Details
.objects_per_run(retained_objects:, runs:) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/heapscope/extrapolation.rb', line 20 def objects_per_run(retained_objects:, runs:) return nil if runs.nil? || runs <= 0 { retained_objects_per_run: (retained_objects.to_f / runs).round(2), label: "per-run retention" } end |
.retention_per_hour(retained_bytes:, elapsed_seconds:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/heapscope/extrapolation.rb', line 8 def retention_per_hour(retained_bytes:, elapsed_seconds:) return nil if elapsed_seconds.nil? || elapsed_seconds <= 0 || retained_bytes.nil? rate = retained_bytes.to_f / elapsed_seconds { bytes_per_second: rate.round(2), bytes_per_hour: (rate * 3600).round, label: "extrapolation", caveat: "At the current observed retention rate — not a prediction of future usage." } end |