Skip to content

Instantly share code, notes, and snippets.

@mmrwoods
Created October 21, 2013 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmrwoods/7080330 to your computer and use it in GitHub Desktop.
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
# 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