Class: AppProfiler::Sampler::StackprofConfig

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

Constant Summary collapse

WALL_INTERVAL =

Default values

5000
CPU_INTERVAL =
5000
OBJECT_INTERVAL =
1000
WALL_MODE_PROBABILITY =
0.8
CPU_MODE_PROBABILITY =
0.1
OBJECT_MODE_PROBABILITY =
0.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wall_interval: WALL_INTERVAL, cpu_interval: CPU_INTERVAL, object_interval: OBJECT_INTERVAL, wall_mode_probability: WALL_MODE_PROBABILITY, cpu_mode_probability: CPU_MODE_PROBABILITY, object_mode_probability: OBJECT_MODE_PROBABILITY) ⇒ StackprofConfig

Returns a new instance of StackprofConfig.



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
# File 'lib/app_profiler/sampler/stackprof_config.rb', line 17

def initialize(
  wall_interval: WALL_INTERVAL,
  cpu_interval: CPU_INTERVAL,
  object_interval: OBJECT_INTERVAL,
  wall_mode_probability: WALL_MODE_PROBABILITY,
  cpu_mode_probability: CPU_MODE_PROBABILITY,
  object_mode_probability: OBJECT_MODE_PROBABILITY
)
  if wall_mode_probability + cpu_mode_probability + object_mode_probability != 1.0
    raise ArgumentError, "mode probabilities must sum to 1"
  end

  @modes_probability = {}
  @modes_interval = {}

  AppProfiler::Backend::StackprofBackend::AVAILABLE_MODES.each do |mode|
    case mode
    when :wall
      @modes_probability[mode] = wall_mode_probability
      @modes_interval[mode] = wall_interval
    when :cpu
      @modes_probability[mode] = cpu_mode_probability
      @modes_interval[mode] = cpu_interval
    when :object
      @modes_probability[mode] = object_mode_probability
      @modes_interval[mode] = object_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/stackprof_config.rb', line 6

def modes_probability
  @modes_probability
end

Instance Method Details

#interval_for(mode) ⇒ Object



47
48
49
# File 'lib/app_profiler/sampler/stackprof_config.rb', line 47

def interval_for(mode)
  @modes_interval[mode]
end