test/stack_printer_test.rb in ruby-prof-0.18.0 vs test/stack_printer_test.rb in ruby-prof-1.0.0
- old
+ new
@@ -39,34 +39,21 @@
result = RubyProf.stop
end_time = Time.now
expected_time = end_time - start_time
file_contents = nil
- assert_nothing_raised { file_contents = print(result) }
+ file_contents = print(result)
re = /Thread: (\d+)(, Fiber: (\d+))? \([\.0-9]+.[\.0-9]+% ~ ([\.0-9]+)\)/
assert_match(re, file_contents)
file_contents =~ re
actual_time = $4.to_f
assert_in_delta(expected_time, actual_time, 0.1)
end
- def test_method_elimination
- RubyProf.start
- 5.times{STPT.new.a}
- result = RubyProf.stop
- assert_nothing_raised {
- # result.dump
- result.eliminate_methods!([/Integer#times/])
- # $stderr.puts "================================"
- # result.dump
- print(result)
- }
- end
-
private
def print(result)
test = caller.first =~ /in `(.*)'/ ? $1 : "test"
- testfile_name = "#{RubyProf.tmpdir}/ruby_prof_#{test}.html"
+ testfile_name = "#{Dir.tmpdir}/ruby_prof_#{test}.html"
# puts "printing to #{testfile_name}"
printer = RubyProf::CallStackPrinter.new(result)
File.open(testfile_name, "w") {|f| printer.print(f, :threshold => 0, :min_percent => 0, :title => "ruby_prof #{test}")}
system("open '#{testfile_name}'") if RUBY_PLATFORM =~ /darwin/ && ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT']=="1"
assert File.exist?(testfile_name), "#{testfile_name} does not exist"