Created
September 14, 2012 14:57
-
-
Save jonleighton/3722432 to your computer and use it in GitHub Desktop.
A look at how ObjectSpace finalizers affect GC time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby test.rb false | |
0.210000 0.000000 0.210000 ( 0.212155) | |
$ ruby test.rb true | |
10.000000 0.280000 10.280000 ( 10.773232) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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