Module: SimpleProfiler
- Extended by:
- ClassConfig
- Defined in:
- lib/simple_profiler.rb,
lib/simple_profiler/event.rb,
lib/simple_profiler/version.rb,
lib/simple_profiler/reporters/logger.rb,
lib/simple_profiler/reporters/summary.rb
Defined Under Namespace
Modules: Reporters
Classes: Event
Constant Summary
collapse
- VERSION =
'0.2.0'
Class Method Summary
collapse
Class Method Details
.profile_class_methods(klass, *methods) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/simple_profiler.rb', line 32
def profile_class_methods(klass, *methods)
methods.each do |method|
new_method = "__#{method}_profiled__"
klass.singleton_class.send :alias_method, new_method, method
klass.send(:define_singleton_method, method) do |*args, &block|
SimpleProfiler.track klass, :class, method, args do
send new_method, *args, &block
end
end
end
end
|
.profile_instance_methods(klass, *methods) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/simple_profiler.rb', line 20
def profile_instance_methods(klass, *methods)
methods.each do |method|
new_method = "__#{method}_profiled__"
klass.send :alias_method, new_method, method
klass.send(:define_method, method) do |*args, &block|
SimpleProfiler.track klass, :instance, method, args do
send new_method, *args, &block
end
end
end
end
|
.track(klass, target, method, args) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/simple_profiler.rb', line 44
def track(klass, target, method, args)
started_at = Time.now
memory = process_memory
result = yield
tracked_args = track_method_args ? args : []
notify Event.new(klass, target, method, tracked_args, started_at, Time.now, memory, process_memory)
result
end
|