ruby-changes:51546
From: normal <ko1@a...>
Date: Wed, 27 Jun 2018 20:32:40 +0900 (JST)
Subject: [ruby-changes:51546] normal:r63754 (trunk): bootstraptest/runner: speed up assert_finish by avoiding sleep
normal 2018-06-27 08:44:00 +0900 (Wed, 27 Jun 2018) New Revision: 63754 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63754 Log: 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. Modified files: trunk/bootstraptest/runner.rb Index: bootstraptest/runner.rb =================================================================== --- bootstraptest/runner.rb (revision 63753) +++ bootstraptest/runner.rb (revision 63754) @@ -373,13 +373,18 @@ def assert_finish(timeout_seconds, tests https://github.com/ruby/ruby/blob/trunk/bootstraptest/runner.rb#L373 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/