Module: Remnant::Filters::ClassMethods
- Included in:
- Remnant::Filters
- Defined in:
- lib/remnant/filters.rb
Instance Method Summary collapse
- #filters ⇒ Object
- #record(filter_type, filter_name, &block) ⇒ Object
- #reset ⇒ Object
- #total_time ⇒ Object
Instance Method Details
#filters ⇒ Object
18 19 20 |
# File 'lib/remnant/filters.rb', line 18 def filters Thread.current['remnant.filters.set'] ||= [] end |
#record(filter_type, filter_name, &block) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/remnant/filters.rb', line 4 def record(filter_type, filter_name, &block) start_time = Time.now result = block.call time = Time.now - start_time filters << {:type => filter_type, :name => filter_name, :time => time, :ms => time * 1000} return result end |
#reset ⇒ Object
13 14 15 16 |
# File 'lib/remnant/filters.rb', line 13 def reset @total_time = nil Thread.current['remnant.filters.set'] = [] end |
#total_time ⇒ Object
22 23 24 |
# File 'lib/remnant/filters.rb', line 22 def total_time @total_time ||= filters.map {|filter| filter[:ms]}.sum end |