Class: Profiler::Api::FunctionProfilingController

Inherits:
Profiler::ApplicationController show all
Defined in:
app/controllers/profiler/api/function_profiling_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



8
9
10
11
12
13
14
15
# File 'app/controllers/profiler/api/function_profiling_controller.rb', line 8

def show
  render json: {
    enabled:    Profiler.function_profiling_enabled,
    max_frames: Profiler.function_profiling_max_frames,
    mode:       Profiler.function_profiling_mode,
    clock:      Profiler.function_profiling_clock
  }
end

#updateObject



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
# File 'app/controllers/profiler/api/function_profiling_controller.rb', line 17

def update
  if params.key?(:enabled)
    Profiler.function_profiling_enabled = params[:enabled] == true || params[:enabled] == "true"
  end

  if params.key?(:max_frames)
    max = params[:max_frames].to_i
    Profiler.function_profiling_max_frames = max.positive? ? max : Profiler.function_profiling_max_frames
  end

  if params.key?(:mode) && %w[full lite].include?(params[:mode])
    Profiler.function_profiling_mode = params[:mode]
  end

  if params.key?(:clock) && %w[wall cpu object].include?(params[:clock])
    Profiler.function_profiling_clock = params[:clock]
  end

  render json: {
    enabled:    Profiler.function_profiling_enabled,
    max_frames: Profiler.function_profiling_max_frames,
    mode:       Profiler.function_profiling_mode,
    clock:      Profiler.function_profiling_clock
  }
end