From a1ba5b6a649a371e9b632cb29cc0547dbe17cade Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 26 Jun 2018 23:44:00 +0000 Subject: bootstraptest/runner: speed up assert_finish by avoiding sleep We may use IO.select to watch for process exit. This speeds up "make test" by 2 seconds for me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/runner.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bootstraptest') diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index e807ce5b62..29dfef771a 100755 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -373,13 +373,18 @@ def assert_finish(timeout_seconds, testsrc, message = '') io = IO.popen("#{@ruby} -W0 #{filename}") pid = io.pid waited = false - tlimit = Time.now + timeout_seconds - while Time.now < tlimit + tlimit = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout_seconds + diff = timeout_seconds + while diff > 0 if Process.waitpid pid, Process::WNOHANG waited = true break end - sleep 0.1 + if IO.select([io], nil, nil, diff) + while String === io.read_nonblock(1024, exception: false) + end + end + diff = tlimit - Process.clock_gettime(Process::CLOCK_MONOTONIC) end if !waited Process.kill(:KILL, pid) -- cgit v1.2.3