class Busted::Counter
Attributes
lock[R]
stack[R]
Public Class Methods
new(stack = Stack.new)
click to toggle source
# File lib/busted/counter.rb, line 7 def initialize(stack = Stack.new) @stack = stack @lock = Monitor.new end
Public Instance Methods
finish()
click to toggle source
# File lib/busted/counter.rb, line 16 def finish lock.synchronize { stack.finished = counts } end
report()
click to toggle source
# File lib/busted/counter.rb, line 20 def report lock.synchronize do started = stack.started finished = stack.finished [:method, :constant].each_with_object({}) do |counter, result| result[counter] = finished[counter] - started[counter] end end end
start()
click to toggle source
# File lib/busted/counter.rb, line 12 def start lock.synchronize { stack.started = counts } end
Private Instance Methods
counts()
click to toggle source
# File lib/busted/counter.rb, line 35 def counts stat = RubyVM.stat { method: stat[:global_method_state], constant: stat[:global_constant_state] } end