Module: NoBrainer::Profiler::ControllerRuntime

Extended by:
ActiveSupport::Concern
Defined in:
lib/no_brainer/profiler/controller_runtime.rb

Overview

Rails specific. TODO Test

Defined Under Namespace

Modules: ClassMethods Classes: Profiler

Instance Method Summary collapse

Instance Method Details

#append_info_to_payload(payload) ⇒ Object



60
61
62
63
# File 'lib/no_brainer/profiler/controller_runtime.rb', line 60

def append_info_to_payload(payload)
  super
  payload[:nobrainer_profiler] = Profiler.current
end

#cleanup_view_runtimeObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/no_brainer/profiler/controller_runtime.rb', line 49

def cleanup_view_runtime
  return super unless Profiler.current

  time_spent_in_db_before_views = Profiler.current.total_duration
  runtime = super
  time_spent_in_db_after_views = Profiler.current.total_duration

  time_spent_in_db_during_views = (time_spent_in_db_after_views - time_spent_in_db_before_views) * 1000
  runtime - time_spent_in_db_during_views
end

#process_action(action, *args) ⇒ Object



42
43
44
45
46
47
# File 'lib/no_brainer/profiler/controller_runtime.rb', line 42

def process_action(action, *args)
  Profiler.spawn_controller_profiler
  super
ensure
  Profiler.cleanup_controller_profiler
end