Sha256: 883bd0697a5c3d05c5526fb10fe4f6f7ea041aafe226d881821c6f690054a3e7
Contents?: true
Size: 655 Bytes
Versions: 13
Compression:
Stored size: 655 Bytes
Contents
class Remnant class Filters module ClassMethods 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 def reset @total_time = nil Thread.current['remnant.filters.set'] = [] end def filters Thread.current['remnant.filters.set'] ||= [] end def total_time @total_time ||= filters.map {|filter| filter[:ms]}.sum end end extend ClassMethods end end
Version data entries
13 entries across 13 versions & 1 rubygems