Skip to content

Instantly share code, notes, and snippets.

@jonleighton
Created September 14, 2012 14:57
Show Gist options
  • Save jonleighton/3722432 to your computer and use it in GitHub Desktop.
Save jonleighton/3722432 to your computer and use it in GitHub Desktop.
A look at how ObjectSpace finalizers affect GC time
$ ruby test.rb false
0.210000 0.000000 0.210000 ( 0.212155)
$ ruby test.rb true
10.000000 0.280000 10.280000 ( 10.773232)
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment