Sha256: adc8dfdfbcdd1d41c5f08fffbfa20625f2b28628bb478fc83ff7f16144a12517

Contents?: true

Size: 1.01 KB

Versions: 23

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require 'ruby-prof'

# Need to use wall time for this test due to the sleep calls
RubyProf::measure_mode = RubyProf::WALL_TIME

module Foo
  def Foo::hello
    sleep(0.5)
  end
end

module Bar
  def Bar::hello
    sleep(0.5)
    Foo::hello
  end
  
  def hello
    sleep(0.5)
    Bar::hello
  end
end

include Bar

class ModuleTest < Test::Unit::TestCase
  def test_nested_modules
    result = RubyProf.profile do
      hello
    end

    methods = result.threads.values.first.sort.reverse
      
    # Length should be 5
    assert_equal(5, methods.length)
    
    method = methods[0]
    assert_equal('ModuleTest#test_nested_modules', method.full_name)
    
    method = methods[1]
    assert_equal('Bar#hello', method.full_name)

    method = methods[2]
    assert_equal('Kernel#sleep', method.full_name)
    
    method = methods[3]
    assert_equal('<Module::Bar>#hello', method.full_name)
    
    method = methods[4]
    assert_equal('<Module::Foo>#hello', method.full_name)
  end 
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
adamh-ruby-prof-0.7.3 test/module_test.rb
skaes-ruby-prof-0.7.3 test/module_test.rb
ruby-prof-danielhoey-0.8.1 test/module_test.rb
ruby-prof-0.8.2 test/module_test.rb
ruby-prof-0.8.1-x86-mingw32 test/module_test.rb
ruby-prof-0.8.1-x86-mswin32 test/module_test.rb
ruby-prof-0.8.1 test/module_test.rb
ruby-prof-0.7.10 test/module_test.rb
ruby-prof-0.7.9 test/module_test.rb
ruby-prof-0.7.8 test/module_test.rb
ruby-prof-0.7.7 test/module_test.rb
ruby-prof-0.7.6 test/module_test.rb
ruby-prof-0.7.5 test/module_test.rb
ruby-prof-0.7.4 test/module_test.rb
rdp-ruby-prof-0.7.4 test/module_test.rb
ruby-prof-0.7.0-x86-mswin32-60 test/module_test.rb
ruby-prof-0.7.1 test/module_test.rb
ruby-prof-0.7.0 test/module_test.rb
ruby-prof-0.7.3 test/module_test.rb
ruby-prof-0.7.3-x86-mswin32-60 test/module_test.rb