aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_helper.rb
diff options
context:
space:
mode:
authorLachlan Sylvester <lachlan.sylvester@hypothetical.com.au>2015-10-17 00:44:12 +1100
committerLachlan Sylvester <lachlan.sylvester@hypothetical.com.au>2015-10-17 00:46:11 +1100
commit5efd82dbe5307982c1eac3ada7a2478993fd59be (patch)
treed8f30b4776d8dc07fdd1b962c183669d29e3a850 /test/test_helper.rb
parente456d734f70de3dfb245c2d2e3ce9c7e22ebdb71 (diff)
downloadrails-5efd82dbe5307982c1eac3ada7a2478993fd59be.tar.gz
rails-5efd82dbe5307982c1eac3ada7a2478993fd59be.tar.bz2
rails-5efd82dbe5307982c1eac3ada7a2478993fd59be.zip
Speed up tests be calling EM.run_deferred_callbacks instead of setting a timer
The run_in_eventmachine test helper method is setting a 0.1 second timer to stop the event machine loop. This causes each test that requires an event machine loop to wait for 0.1 second regardless of how long the test takes to process. This changes that to call EM.run_deferred_callbacks, which immediatly process pending actions in the event loop and then is able to exit the event loop without doing any waiting. Before this change, running tests produced Finished in 2.957857s, 15.8899 runs/s, 27.7228 assertions/s. After, the tests get Finished in 0.065942s, 712.7514 runs/s, 1243.5237 assertions/s.
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 49fb1495f4..a2e0df8fa8 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -33,7 +33,8 @@ class ActionCable::TestCase < ActiveSupport::TestCase
EM.run do
yield
- EM::Timer.new(0.1) { EM.stop }
+ EM.run_deferred_callbacks
+ EM.stop
end
end
end