Sha256: 3e84aaaaa4624cbf9d86464df2366ba8c4844e41a3f16396a05e63adb8b97725

Contents?: true

Size: 899 Bytes

Versions: 1

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

module HeapProfiler
  class Diff
    class DumpSubset
      def initialize(path, generation)
        @path = path
        @generation = generation
      end

      def each_object(&block)
        Parser.load_many(@path, since: @generation, &block)
      end
    end

    attr_reader :allocated

    def initialize(report_directory)
      @report_directory = report_directory
      @allocated = open_dump('allocated')
      @generation = Integer(File.read(File.join(report_directory, 'generation.info')))
      @generation = nil if @generation == 0
    end

    def allocated_diff
      @allocated_diff ||= DumpSubset.new(@allocated.path, @generation)
    end

    def retained_diff
      @retained_diff ||= DumpSubset.new(open_dump('retained').path, @generation)
    end

    private

    def open_dump(name)
      Dump.open(@report_directory, name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heap-profiler-0.7.0 lib/heap_profiler/diff.rb