Sha256: 421f7c5b878f518838dddfbcf29bb86d528b5f97bacfb51c2db2b24421da83e6

Contents?: true

Size: 510 Bytes

Versions: 3

Compression:

Stored size: 510 Bytes

Contents

module Busted
  class Counter

    def start
      @started = counts
    end

    def finish
      @finished = counts
    end

    def report
      [:method, :constant].each_with_object({}) do |counter, result|
        result[counter] = finished[counter] - started[counter]
      end
    end

    private

    attr_reader :started, :finished

    def counts
      stat = RubyVM.stat
      {
        method:   stat[:global_method_state],
        constant: stat[:global_constant_state]
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
busted-0.2.1 lib/busted/counter.rb
busted-0.2.0 lib/busted/counter.rb
busted-0.1.0 lib/busted/counter.rb