test/test_helper.rb in ruby-prof-0.15.9 vs test/test_helper.rb in ruby-prof-0.16.0

- old
+ new

@@ -26,13 +26,26 @@ require 'ruby-prof' require 'minitest/autorun' class TestCase < Minitest::Test + # I know this sucks, but ... def assert_nothing_raised(*) yield end + + def before_setup + # make sure to exclude all threads except the one running the test + # minitest allocates a thread pool and they would otherwise show + # up in the profile data, breaking tests randomly + RubyProf.exclude_threads = Thread.list.select{|t| t != Thread.current} + end + + def after_teardown + # reset exclude threads after testing + RubyProf.exclude_threads = nil + end end require File.expand_path('../prime', __FILE__) # Some classes used in measurement tests @@ -83,24 +96,36 @@ goodbye end end class C7 - def self.hello + def self.busy_wait t = Time.now.to_f while Time.now.to_f - t < 0.1; end end - def hello + def self.sleep_wait + sleep 0.1 + end + + def busy_wait t = Time.now.to_f while Time.now.to_f - t < 0.2; end end + + def sleep_wait + sleep 0.2 + end end module M7 - def hello + def busy_wait t = Time.now.to_f while Time.now.to_f - t < 0.3; end + end + + def sleep_wait + sleep 0.3 end end class C8 include M7