public
Created

A look at how ObjectSpace finalizers affect GC time

  • Download Gist
results.txt
1 2 3 4
$ ruby test.rb false
0.210000 0.000000 0.210000 ( 0.212155)
$ ruby test.rb true
10.000000 0.280000 10.280000 ( 10.773232)
test.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
require 'benchmark'
 
n = 10_000_000
finalizer = proc { } if ARGV[0] == 'true'
 
GC.disable
n.times {
o = Object.new
ObjectSpace.define_finalizer(o, finalizer) if finalizer
}
 
puts Benchmark.measure {
GC.enable
GC.start
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.