test/test_evdispatch.rb in evdispatch-0.2.2 vs test/test_evdispatch.rb in evdispatch-0.2.4
- old
+ new
@@ -1,53 +1,43 @@
require File.dirname(__FILE__) + '/test_helper.rb'
class TestEvdispatch < Test::Unit::TestCase
- def is_linux?
- !(`uname`.grep(/linux/i)).empty?
- end
-
def test_object_test
- # start up the test server
- if is_linux?
- pid = fork do
- require File.dirname(__FILE__) + '/../ext/revdispatch/server'
- start_test_server
- end
- sleep 1
- else
- STDERR.puts "make sure '#{File.dirname(__FILE__) + '/../ext/revdispatch/server'} start' is running..."
- end
-
d = Evdispatch::Loop.new
# start the event loop thread
d.start
- begin
+ # increase this to verify
+ 1.times do
- ObjectSpace.garbage_collect
+ begin
- 10.times do
- begin
- start_count = ObjectSpace.each_object { }
- duration = run_trial(d, 100)
- new_count = ObjectSpace.each_object { }
- puts "10 trials: #{duration} seconds, new objects #{new_count - start_count}, #{new_count} - #{start_count}"
- end
+ ObjectSpace.garbage_collect
- begin
- start_count = ObjectSpace.each_object { }
- duration = run_trial(d, 200)
- new_count = ObjectSpace.each_object { }
- puts "100 trials: #{duration} seconds, new objects #{new_count - start_count}, #{new_count} - #{start_count}"
+ 10.times do
+ begin
+ start_count = ObjectSpace.each_object { }
+ duration = run_trial(d, 100)
+ new_count = ObjectSpace.each_object { }
+ puts "10 trials: #{duration} seconds, new objects #{new_count - start_count}, #{new_count} - #{start_count}"
+ end
+
+ begin
+ start_count = ObjectSpace.each_object { }
+ duration = run_trial(d, 200)
+ new_count = ObjectSpace.each_object { }
+ puts "100 trials: #{duration} seconds, new objects #{new_count - start_count}, #{new_count} - #{start_count}"
+ end
+
end
+ rescue => e
+ puts e.message, e.backtrace
end
- rescue => e
- puts e.message, e.backtrace
end
count = ObjectSpace.each_object { }
puts "Final Total objects: #{count}"
count = nil
@@ -55,11 +45,9 @@
count = ObjectSpace.each_object { }
puts "After garbage collection objects: #{count}"
# sometime later you can stop the event loop
d.stop
- ensure
- Process.kill('HUP', pid) if is_linux?
end
def request_bytes_from( d, base, amount, range )
ids = []
amount.times do|i|