Sha256: b2eedb35565b381260610de9ca61da9d233ca9f6948a9e6a39e56065429c4f09

Contents?: true

Size: 971 Bytes

Versions: 6

Compression:

Stored size: 971 Bytes

Contents

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

require File.expand_path('../test_helper', __FILE__)
require 'fileutils'
require 'tmpdir'
require_relative 'prime'

# --  Tests ----
class PrinterCallTreeTest < TestCase
  def setup
    # WALL_TIME so we can use sleep in our test and get same measurements on linux and windows
    RubyProf::measure_mode = RubyProf::WALL_TIME
    @result = RubyProf.profile do
      run_primes(1000, 5000)
    end
  end

  def test_call_tree_string
    printer = RubyProf::CallTreePrinter.new(@result)

    printer.print(:path => Dir.tmpdir)
    main_output_file_name = File.join(Dir.tmpdir, "callgrind.out.#{$$}")
    assert(File.exist?(main_output_file_name))
    output = File.read(main_output_file_name)
    assert_match(/fn=Object::find_primes/i, output)
    assert_match(/events: wall_time/i, output)
    refute_match(/d\d\d\d\d\d/, output) # old bug looked [in error] like Object::run_primes(d5833116)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-prof-1.5.0-x64-mingw-ucrt test/printer_call_tree_test.rb
ruby-prof-1.5.0 test/printer_call_tree_test.rb
ruby-prof-1.4.5-x64-mingw-ucrt test/printer_call_tree_test.rb
ruby-prof-1.4.5 test/printer_call_tree_test.rb
ruby-prof-1.4.4-x64-mingw-ucrt test/printer_call_tree_test.rb
ruby-prof-1.4.4 test/printer_call_tree_test.rb