module Flows::Plugin::Profiler::Wrapper
@api private
Public Class Methods
make_instance_wrapper(method_name)
click to toggle source
Calls superclass method
# File lib/flows/plugin/profiler/wrapper.rb, line 7 def make_instance_wrapper(method_name) # rubocop:disable Metrics/MethodLength Module.new.tap do |mod| mod.define_method(method_name) do |*args, &block| # rubocop:disable Metrics/MethodLength thread = Thread.current klass = self.class return super(*args, &block) unless thread[THREAD_VAR_FLAG] report = thread[THREAD_VAR_REPORT] report.add(:started, klass, :instance, method_name, nil) before = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_microsecond) super(*args, &block) ensure if before after = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_microsecond) report.add(:finished, klass, :instance, method_name, after - before) end end end end
make_singleton_wrapper(method_name)
click to toggle source
Calls superclass method
# File lib/flows/plugin/profiler/wrapper.rb, line 29 def make_singleton_wrapper(method_name) # rubocop:disable Metrics/MethodLength Module.new.tap do |mod| mod.define_method(method_name) do |*args, &block| # rubocop:disable Metrics/MethodLength thread = Thread.current return super(*args, &block) unless thread[THREAD_VAR_FLAG] report = thread[THREAD_VAR_REPORT] report.add(:started, self, :singleton, method_name, nil) before = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_microsecond) super(*args, &block) ensure if before after = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_microsecond) report.add(:finished, self, :singleton, method_name, after - before) end end end end