Sha256: f92227fb4c6aa48e41e76e958ccabef72147f3309cd6efe18d49892de8f1e09b
Contents?: true
Size: 801 Bytes
Versions: 1
Compression:
Stored size: 801 Bytes
Contents
require "monitor" require "busted/stack" module Busted class Counter def initialize(stack = Stack.new) @stack = stack @lock = Monitor.new end def start lock.synchronize { stack.started = counts } end def finish lock.synchronize { stack.finished = counts } end 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 private attr_reader :stack, :lock def counts stat = RubyVM.stat { method: stat[:global_method_state], constant: stat[:global_constant_state] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
busted-0.2.3 | lib/busted/counter.rb |