Module: HeapScope::Classification

Defined in:
lib/heapscope/extrapolation.rb

Overview

Classifies churn vs sticky populations for reports.

Class Method Summary collapse

Class Method Details

.churn_vs_leak(allocated:, retained:) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/heapscope/extrapolation.rb', line 34

def churn_vs_leak(allocated:, retained:)
  allocated = allocated.to_i
  retained = retained.to_i
  return :insufficient_data if allocated <= 0

  ratio = retained.to_f / allocated
  if allocated > 10_000 && ratio < 0.05
    :high_churn_low_retention
  elsif allocated < 1_000 && ratio > 0.5
    :sticky
  elsif allocated > 10_000 && ratio > 0.3
    :severe
  else
    :normal
  end
end