Sha256: bdcf20a0c5515a21cec9ad3c30eca4a9b78f1b91872bb2de1453521ca50b3718

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

require 'objspace'
require "iseq_collector/version"

case
when RUBY_VERSION < '2.3.0'
  module ObjectSpace
    def self.each_iseq
      ObjectSpace.each_object(RubyVM::InstructionSequence){|iseq|
        yield iseq
      }
    end
    def self.count_iseq
      cnt = 0
      ObjectSpace.each_object(RubyVM::InstructionSequence){|iseq|
        cnt += 1
      }
      cnt
    end
  end

when RUBY_VERSION >= '2.3.0' && !ObjectSpace.respond_to?(:count_iseq)
  require_relative 'iseq_collector.so'
else
  # do nothing.
end

module ObjectSpace
  def self.memsize_of_all_iseq
    size = 0
    ObjectSpace.each_iseq{|iseq|
      size += ObjectSpace.memsize_of(iseq)
    }
    size
  end
end

module IseqCollector
  # we have no code here.
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iseq_collector-0.5.0 lib/iseq_collector.rb
iseq_collector-0.4.0 lib/iseq_collector.rb