class MultiPrinterTest

  1. test/multi_printer_test.rb

Methods

Public Instance

  1. setup
  2. test_all_profiles_can_be_created

Public Instance methods

setup ()
[show source]
# File test/multi_printer_test.rb, line 29
def setup
  # Need to use wall time for this test due to the sleep calls
  RubyProf::measure_mode = RubyProf::WALL_TIME
end
test_all_profiles_can_be_created ()
[show source]
# File test/multi_printer_test.rb, line 34
  def test_all_profiles_can_be_created
    start_time = Time.now
    RubyProf.start
    5.times{MSTPT.new.a}
    result = RubyProf.stop
    end_time = Time.now
    expected_time = end_time - start_time
    stack = graph = nil
    assert_nothing_raised { stack, graph = print(result) }
    re = Regexp.new('
\s*<table>
\s*<tr>
\s*<th>Thread ID</th>
\s*<th>Total Time</th>
\s*</tr>
\s*
\s*<tr>
\s*<td><a href="#\d+">\d+</a></td>
\s*<td>([\.0-9]+)</td>
\s*</tr>
\s*
\s*</table>')
    assert graph =~ re
    display_time = $1.to_f
    difference = (expected_time-display_time).abs
    assert_in_delta expected_time, display_time, 0.005
  end