diff options
author | Henare Degan <henare.degan@gmail.com> | 2012-12-08 16:44:10 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2012-12-08 16:44:10 +1100 |
commit | 308d338a172b11230bafa784f96fcf1eb5e6e981 (patch) | |
tree | f65d33467f933c0f0c1711fc516371adcd8633e8 | |
parent | eac295b32d8b135b4aa19a868183fa1591ff0f89 (diff) |
Only trigger garbage collection every 4 seconds - speeds up the whole test suite by ~35% on my machine
Via https://37signals.com/svn/posts/2742-the-road-to-faster-tests
-rw-r--r-- | spec/spec_helper.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d4dad591d..839e6125e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,6 +46,20 @@ Spec::Runner.configure do |config| :holidays, :track_things_sent_emails + # This section makes the garbage collector run less often to speed up tests + last_gc_run = Time.now + + config.before(:each) do + GC.disable + end + + config.after(:each) do + if Time.now - last_gc_run > 4 + GC.enable + GC.start + last_gc_run = Time.now + end + end # == Fixtures # |