Sha256: f3bbc1b7eec3cae8d2785a90d948c6680aa8491ba90bde5b59928c6386cf2de4

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

require_relative 'test_helper'

class TestReporter < Minitest::Test

  class Foo; end

  def allocate_strings(n)
    n.times do
      ""
    end
  end

  def test_counts
    a = nil
    result = MemoryProfiler::Reporter.report do
      allocate_strings(10)
      a = "hello"
    end
    assert_equal(11, result.total_allocated)
    assert_equal(1, result.total_retained)
    assert_equal(1, result.retained_objects_by_location.length)
  end

  def test_class_tracing
    result = MemoryProfiler::Reporter.report(:trace => [Foo]) do
      "hello"
      "hello"
      Foo.new
    end
    assert_equal(1, result.total_allocated)
    assert_equal(0, result.total_retained)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
memory_profiler-0.0.4 test/test_reporter.rb