class Wildsight::Profiler::Profile
Attributes
options[RW]
Public Class Methods
new(name, parent)
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 44 def initialize(name, parent) @name = name @parent = parent @subtimes = [] @result = nil @exception = nil end
Public Instance Methods
<<(time)
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 80 def <<(time) @subtimes << time end
close()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 67 def close @parent << raw if @parent @parent end
duration()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 88 def duration return raw if options[:raw] return raw - subtimes end
exception()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 76 def exception @exception end
export()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 97 def export { before: @before, after: @after, duration: duration, raw: raw } end
profile!(&block)
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 57 def profile!(&block) @before = DateTime.now.to_f begin @result = block.call rescue Exception => e @exception = e end @after = DateTime.now.to_f end
raw()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 93 def raw (@after - @before) * 1000 end
result()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 72 def result @result end
set(before, after)
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 52 def set(before, after) @before = before @after = after end
subtimes()
click to toggle source
# File lib/wildsight/profiler/profiler.rb, line 84 def subtimes @subtimes.inject(0.0) { |c,x| c + x } end