Class: AppProfiler::Sampler::VernierConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/app_profiler/sampler/vernier_config.rb

Constant Summary collapse

WALL_INTERVAL =
5000
RETAINED_INTERVAL =
5000
WALL_MODE_PROBABILITY =
1.0
RETAINED_MODE_PROBABILITY =
0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wall_interval: WALL_INTERVAL, retained_interval: RETAINED_INTERVAL, wall_mode_probability: WALL_MODE_PROBABILITY, retained_mode_probability: RETAINED_MODE_PROBABILITY) ⇒ VernierConfig

Returns a new instance of VernierConfig.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/app_profiler/sampler/vernier_config.rb', line 14

def initialize(
  wall_interval: WALL_INTERVAL,
  retained_interval: RETAINED_INTERVAL,
  wall_mode_probability: WALL_MODE_PROBABILITY,
  retained_mode_probability: RETAINED_MODE_PROBABILITY
)
  if wall_mode_probability + retained_mode_probability != 1.0
    raise ArgumentError, "mode probabilities must sum to 1"
  end

  @modes_probability = {}
  @modes_interval = {}

  AppProfiler::Backend::VernierBackend::AVAILABLE_MODES.each do |mode|
    case mode
    when :wall
      @modes_probability[mode] = wall_mode_probability
      @modes_interval[mode] = wall_interval
    when :retained
      @modes_probability[mode] = retained_mode_probability
      @modes_interval[mode] = retained_interval
    end
  end
end

Instance Attribute Details

#modes_probabilityObject (readonly)

Returns the value of attribute modes_probability.



6
7
8
# File 'lib/app_profiler/sampler/vernier_config.rb', line 6

def modes_probability
  @modes_probability
end

Instance Method Details

#interval_for(mode) ⇒ Object



39
40
41
# File 'lib/app_profiler/sampler/vernier_config.rb', line 39

def interval_for(mode)
  @modes_interval[mode]
end