Class: SpeedGun::Profiler
- Inherits:
-
Object
- Object
- SpeedGun::Profiler
show all
- Defined in:
- lib/speed_gun/profiler.rb
Defined Under Namespace
Classes: ActionControllerProfiler, ActionMailerProfiler, ActionViewProfiler, ActiveJobProfiler, ActiveRecordProfiler, ActiveSupportNotificatiosProfiler, ActiveSupportProfiler, HTTPProfiler, LineProfiler, RackProfiler
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.ignore? ⇒ Boolean
10
11
12
13
14
|
# File 'lib/speed_gun/profiler.rb', line 10
def self.ignore?
SpeedGun.config.ignored_profilers.any? do |ignore|
name.include?(ignore)
end
end
|
.profile(*args, &block) ⇒ Object
6
7
8
|
# File 'lib/speed_gun/profiler.rb', line 6
def self.profile(*args, &block)
new.profile(*args, &block)
end
|
Instance Method Details
#profile(name = self.class.name, payload = {}) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/speed_gun/profiler.rb', line 16
def profile(name = self.class.name, payload = {})
started_at = Time.now
payload[:backtrace] ||= SpeedGun.get_backtrace
event = SpeedGun::Event.new(name, payload, started_at)
result = yield(event)
event.finish!
SpeedGun.record(event) unless self.class.ignore?
result
end
|