Sha256: c58d8582618a46a8f63be0c91cdc1e49bf830a0faceb8a4c25f0ec0d8bec852d

Contents?: true

Size: 1.01 KB

Versions: 26

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

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


# --  Tests ----
class ExcludeThreadsTest < 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

    # exclude_threads already includes the minitest thread pool
    RubyProf.exclude_threads += [ thread2 ]

    RubyProf.start

    thread1.join
    thread2.join

    result = RubyProf.stop

    assert_equal(2, result.threads.length)

    output = Array.new
    result.threads.each do |thread|
      thread.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

26 entries across 26 versions & 2 rubygems

Version Path
ruby-prof-1.5.0-x64-mingw-ucrt test/exclude_threads_test.rb
ruby-prof-1.5.0 test/exclude_threads_test.rb
ruby-prof-1.4.5-x64-mingw-ucrt test/exclude_threads_test.rb
ruby-prof-1.4.5 test/exclude_threads_test.rb
ruby-prof-1.4.4-x64-mingw-ucrt test/exclude_threads_test.rb
ruby-prof-1.4.4 test/exclude_threads_test.rb
ruby-prof-1.4.3-x64-mingw32 test/exclude_threads_test.rb
ruby-prof-1.4.3 test/exclude_threads_test.rb
ruby-prof-1.4.2-x64-mingw32 test/exclude_threads_test.rb
ruby-prof-1.4.2 test/exclude_threads_test.rb
ruby-prof-1.4.1-x64-mingw32 test/exclude_threads_test.rb
ruby-prof-1.4.1 test/exclude_threads_test.rb
ruby-prof-1.4.0-x64-mingw32 test/exclude_threads_test.rb
ruby-prof-1.4.0 test/exclude_threads_test.rb
ruby-prof-1.3.2 test/exclude_threads_test.rb
ruby-prof-1.3.1-x64-mingw32 test/exclude_threads_test.rb
ruby-prof-1.3.1 test/exclude_threads_test.rb
ruby-prof-1.3.0-x64-mingw32 test/exclude_threads_test.rb
ruby-prof-1.3.0 test/exclude_threads_test.rb
ruby-prof-1.2.0 test/exclude_threads_test.rb