Sha256: c7ce7e3d667cd3bed7e7d57debf54d20a3b27601b638b7c89a946654e6d6fd81

Contents?: true

Size: 855 Bytes

Versions: 6

Compression:

Stored size: 855 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')))
    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

6 entries across 6 versions & 1 rubygems

Version Path
heap-profiler-0.6.0 lib/heap_profiler/diff.rb
heap-profiler-0.5.0 lib/heap_profiler/diff.rb
heap-profiler-0.4.0 lib/heap_profiler/diff.rb
heap-profiler-0.3.0 lib/heap_profiler/diff.rb
heap-profiler-0.2.1 lib/heap_profiler/diff.rb
heap-profiler-0.2.0 lib/heap_profiler/diff.rb