Created
October 21, 2013 08:16
-
-
Save mmrwoods/7080330 to your computer and use it in GitHub Desktop.
Disable GC and running the collector manually every few seconds for cuke runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from Jamis Buck's post "The road to faster tests" | |
# http://37signals.com/svn/posts/2742-the-road-to-faster-tests | |
# | |
# Disabling GC and running the collector manually every few seconds | |
# knocks 25-30% off the time taken to run all of my non-js scenarios | |
# on ruby 1.9.3p448, without any other memory management tuning. | |
DEFERRED_GC_THRESHOLD = (ENV['CUCUMBER_DEFERRED_GC_THRESHOLD'] || 3.0).to_f | |
last_gc_run = Time.now | |
Before do | |
GC.disable if DEFERRED_GC_THRESHOLD > 0 | |
end | |
After do | |
if DEFERRED_GC_THRESHOLD > 0 && Time.now - last_gc_run >= DEFERRED_GC_THRESHOLD | |
GC.enable | |
GC.start | |
last_gc_run = Time.now | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment