Module: Perfetto::Interceptor::ImplMethods
- Defined in:
- lib/perfetto/interceptor.rb
Overview
Real Implementation
Instance Method Summary collapse
- #perfetto_trace_all ⇒ Object
- #perfetto_trace_class_method(method_name) ⇒ Object
- #perfetto_trace_instance_method(method_name) ⇒ Object
- #perfetto_traced_class_method?(method_name) ⇒ Boolean
- #perfetto_traced_class_methods ⇒ Object
- #perfetto_traced_instance_method?(method_name) ⇒ Boolean
- #perfetto_traced_instance_methods ⇒ Object
Instance Method Details
#perfetto_trace_all ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/perfetto/interceptor.rb', line 78 def perfetto_trace_all original_method_added = singleton_class.instance_method(:method_added) define_singleton_method(:method_added) do |method_name| original_method_added.bind(self).call(method_name) return if perfetto_traced_instance_method?(method_name) perfetto_trace_instance_method method_name end original_singleton_method_added = singleton_class.instance_method(:singleton_method_added) define_singleton_method(:singleton_method_added) do |method_name| original_singleton_method_added.bind(self).call(method_name) return if perfetto_traced_class_method?(method_name) perfetto_trace_class_method method_name end end |
#perfetto_trace_class_method(method_name) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/perfetto/interceptor.rb', line 60 def perfetto_trace_class_method(method_name) return if method_name.to_s.start_with? "_pfc_" perfetto_traced_class_methods << method_name original_method = singleton_class.instance_method(method_name) singleton_class.send(:alias_method, "_pfc_#{method_name}", method_name) define_singleton_method(method_name) do |*args, **kwargs, &block| category = name task_name = "#{name}::#{method_name}" Perfetto.trace_event_begin category, task_name original_method.bind(self).call(*args, **kwargs, &block) ensure Perfetto.trace_event_end name end end |
#perfetto_trace_instance_method(method_name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/perfetto/interceptor.rb', line 42 def perfetto_trace_instance_method(method_name) return if method_name.to_s.start_with? "_pfi_" perfetto_traced_instance_methods << method_name original_method = instance_method(method_name) alias_method "_pfi_#{method_name}", method_name define_method(method_name) do |*args, **kwargs, &block| category = self.class.name task_name = "#{self.class.name}##{method_name}" Perfetto.trace_event_begin category, task_name original_method.bind(self).call(*args, **kwargs, &block) ensure Perfetto.trace_event_end self.class.name end end |
#perfetto_traced_class_method?(method_name) ⇒ Boolean
100 101 102 |
# File 'lib/perfetto/interceptor.rb', line 100 def perfetto_traced_class_method?(method_name) perfetto_traced_class_methods.include? method_name end |
#perfetto_traced_class_methods ⇒ Object
108 109 110 |
# File 'lib/perfetto/interceptor.rb', line 108 def perfetto_traced_class_methods @perfetto_traced_class_methods ||= [] end |
#perfetto_traced_instance_method?(method_name) ⇒ Boolean
96 97 98 |
# File 'lib/perfetto/interceptor.rb', line 96 def perfetto_traced_instance_method?(method_name) perfetto_traced_instance_methods.include? method_name end |
#perfetto_traced_instance_methods ⇒ Object
104 105 106 |
# File 'lib/perfetto/interceptor.rb', line 104 def perfetto_traced_instance_methods @perfetto_traced_instance_methods ||= [] end |