File: measure_gc_time_test.rb

package info (click to toggle)
ruby-prof 0.17.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,656 kB
  • sloc: ruby: 5,043; ansic: 2,175; makefile: 6
file content (36 lines) | stat: -rwxr-xr-x 776 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
34
35
36
#!/usr/bin/env ruby
# encoding: UTF-8

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

class MeasureGCTimeTest < TestCase
  include MemoryTestHelper

  def test_gc_time_mode
    RubyProf::measure_mode = RubyProf::GC_TIME
    assert_equal(RubyProf::GC_TIME, RubyProf::measure_mode)
  end

  def test_gc_time_enabled_defined
    assert(defined?(RubyProf::GC_TIME_ENABLED))
  end

  if RubyProf::GC_TIME_ENABLED
    def test_gc_time
      RubyProf::measure_mode = RubyProf::GC_TIME
      RubyProf.enable_gc_stats_if_needed

      t = RubyProf.measure_gc_time
      assert_kind_of Float, t

      GC.start

      u = RubyProf.measure_gc_time
      assert u > t, [t, u].inspect

      memory_test_helper
    ensure
      RubyProf.disable_gc_stats_if_needed
    end
  end
end