File: measure_memory_test.rb

package info (click to toggle)
ruby-prof 0.16.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,680 kB
  • ctags: 972
  • sloc: ruby: 4,552; ansic: 1,888; makefile: 6
file content (33 lines) | stat: -rwxr-xr-x 923 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby
# encoding: UTF-8

require File.expand_path('../test_helper', __FILE__)

class MeasureMemoryTest < TestCase
  include MemoryTestHelper

  def test_memory_mode
    RubyProf::measure_mode = RubyProf::MEMORY
    assert_equal(RubyProf::MEMORY, RubyProf::measure_mode)
  end

  def test_memory_enabled_defined
    assert(defined?(RubyProf::MEMORY_ENABLED))
  end

  if RubyProf::MEMORY_ENABLED
    def test_memory
      RubyProf::measure_mode = RubyProf::MEMORY
      RubyProf.enable_gc_stats_if_needed
      t = RubyProf.measure_memory
      assert_kind_of Float, t
      u = RubyProf.measure_memory
      assert_operator u, :>, t
      total = memory_test_helper
      assert(total > 0, 'Should measure more than zero kilobytes of memory usage')
      refute_equal(0, total % 1, 'Should not truncate fractional kilobyte measurements')
    ensure
      RubyProf.disable_gc_stats_if_needed
    end
  end
end