drop deferred garbage collection
This commit is contained in:
parent
60a5d2a5ba
commit
3a92efbfaf
3 changed files with 0 additions and 60 deletions
|
|
@ -89,12 +89,3 @@ After do |scenario|
|
|||
Capybara.send(:session_pool).delete_if { |key, value| key =~ /selenium/i }
|
||||
end
|
||||
end
|
||||
|
||||
# # https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
||||
# require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "deferred_garbage_collection")
|
||||
# Before do
|
||||
# DeferredGarbageCollection.start
|
||||
# end
|
||||
# After do
|
||||
# DeferredGarbageCollection.reconsider
|
||||
# end
|
||||
|
|
|
|||
|
|
@ -92,13 +92,3 @@ RSpec.configure do |config|
|
|||
AppConfig.reset_dynamic!
|
||||
end
|
||||
end
|
||||
|
||||
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
||||
RSpec.configure do |config|
|
||||
config.before(:all) do
|
||||
DeferredGarbageCollection.start
|
||||
end
|
||||
config.after(:all) do
|
||||
DeferredGarbageCollection.reconsider
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
|
||||
class DeferredGarbageCollection
|
||||
|
||||
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f #used to be 10.0
|
||||
|
||||
@@last_gc_run = Time.now
|
||||
|
||||
def self.start
|
||||
return if unsupported_environment
|
||||
GC.disable if DEFERRED_GC_THRESHOLD > 0
|
||||
end
|
||||
|
||||
def self.memory_threshold
|
||||
@mem = %x(free 2>/dev/null).to_s.split(" ")
|
||||
return nil if @mem.empty?
|
||||
@mem[15].to_i / (@mem[7].to_i/100)
|
||||
end
|
||||
|
||||
def self.reconsider
|
||||
return if unsupported_environment
|
||||
|
||||
if (percent_used = self.memory_threshold)
|
||||
running_out_of_memory = percent_used > 90
|
||||
else
|
||||
running_out_of_memory = false
|
||||
end
|
||||
|
||||
if( (DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD) || running_out_of_memory )
|
||||
GC.enable
|
||||
GC.start
|
||||
GC.disable
|
||||
@@last_gc_run = Time.now
|
||||
end
|
||||
end
|
||||
|
||||
def self.unsupported_environment
|
||||
ENV['TRAVIS'] # TODO: enable for ruby 1.9.3 or more RAM
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in a new issue