Skip to content

Instantly share code, notes, and snippets.

@modsognir
Created June 3, 2011 03:38
Show Gist options
  • Select an option

  • Save modsognir/1005830 to your computer and use it in GitHub Desktop.

Select an option

Save modsognir/1005830 to your computer and use it in GitHub Desktop.
Speed up cucumber
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f
@@last_gc_run = Time.now
def self.start
GC.disable if DEFERRED_GC_THRESHOLD > 0
end
def self.reconsider
if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
GC.enable
GC.start
GC.disable
@@last_gc_run = Time.now
end
end
end
Before do
DeferredGarbageCollection.start
end
After do
DeferredGarbageCollection.reconsider
end
@schlick
Copy link

schlick commented Jun 15, 2011

Does it still segfault?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment