Sha256: b10482582c4daa6245924d178a7cd916166d7b3a0a6d339272116926c8fb866e

Contents?: true

Size: 883 Bytes

Versions: 20

Compression:

Stored size: 883 Bytes

Contents

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

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

class CallTreeVisitorTest < TestCase
  def setup
    # Need to use wall time for this test due to the sleep calls
    RubyProf::measure_mode = RubyProf::WALL_TIME
  end

  def test_visit
    result = RubyProf.profile do
      RubyProf::C1.sleep_wait
    end

    visitor = RubyProf::CallTreeVisitor.new(result.threads.first.call_tree)

    method_names = Array.new

    visitor.visit do |call_tree, event|
      method_names << call_tree.target.full_name if event == :enter
    end

    assert_equal(3, method_names.length)
    assert_equal("CallTreeVisitorTest#test_visit", method_names[0])
    assert_equal("<Class::RubyProf::C1>#sleep_wait", method_names[1])
    assert_equal("Kernel#sleep", method_names[2])
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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