Sha256: 2dd35b64a669859a45701965c54103faf6371b0cd4515fcf862b913dafb6713c

Contents?: true

Size: 992 Bytes

Versions: 23

Compression:

Stored size: 992 Bytes

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'ruby-prof'


# --  Tests ----
class ExcludeThreadsTest < Test::Unit::TestCase
  def test_exclude_threads

    def thread1_proc
      sleep(0.5)
      sleep(2)
    end

    def thread2_proc
      sleep(0.5)
      sleep(2)
    end
        
    thread1 = Thread.new do 
      thread1_proc
    end

    thread2 = Thread.new do
      thread2_proc
    end

    RubyProf::exclude_threads = [ thread2 ]
 
    RubyProf.start

    thread1.join
    thread2.join

    result = RubyProf.stop

    RubyProf::exclude_threads = nil

    assert_equal(2, result.threads.length)

    output = Array.new
    result.threads.each do | thread_id, methods |
      methods.each do | m |
        if m.full_name.index("ExcludeThreadsTest#thread") == 0
          output.push(m.full_name)
        end
      end
    end

    assert_equal(1, output.length)
    assert_equal("ExcludeThreadsTest#thread1_proc", output[0])
  end
end

Version data entries

23 entries across 23 versions & 5 rubygems

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