Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 21 lines (16 sloc) 0.482 kB
2787d87 @justinfrench Deferring garbage collection cuts the time to run the test suite down…
authored
1 # Taken from http://makandra.com/notes/950-speed-up-rspec-by-deferring-garbage-collection
2 class DeferredGarbageCollection
3
4 DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f
5
6 @@last_gc_run = Time.now
7
8 def self.start
9 GC.disable if DEFERRED_GC_THRESHOLD > 0
10 end
11
12 def self.reconsider
13 if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
14 GC.enable
15 GC.start
16 GC.disable
17 @@last_gc_run = Time.now
18 end
19 end
20
21 end
Something went wrong with that request. Please try again.