Sha256: 544728a871553c35331444ad5d407bfe9eca2f23fc5489b209bc64d482b60f04
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
module Flows module Plugin module Profiler # @api private module Wrapper class << self 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 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 end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flows-0.6.0 | lib/flows/plugin/profiler/wrapper.rb |
flows-0.5.1 | lib/flows/plugin/profiler/wrapper.rb |
flows-0.5.0 | lib/flows/plugin/profiler/wrapper.rb |