Created
February 19, 2012 19:20
-
-
Save headius/1865276 to your computer and use it in GitHub Desktop.
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
# Adapted from a script by Evan Phoenix | |
require 'benchmark' | |
GC::Profiler.enable | |
class Simple | |
attr_accessor :next | |
end | |
top = Simple.new | |
puts Benchmark.measure { | |
outer = 10 | |
total = 100000 | |
per = 100 | |
outer.times do | |
total.times do | |
per.times { Simple.new } | |
s = Simple.new | |
top.next = s | |
top = s | |
end | |
end | |
} | |
puts "GC time: #{GC::Profiler.total_time}s" |
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
system ~/projects/gc_tests $ rvm 1.9.3 do ruby -v gc_stress.rb | |
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0] | |
20.820000 0.240000 21.060000 ( 21.070793) | |
GC time: 2.29012300000049s | |
system ~/projects/gc_tests $ rvm ruby-head do ruby -v gc_stress.rb | |
ruby 2.0.0dev (2012-02-19 trunk 34699) [x86_64-darwin10.8.0] | |
21.740000 0.250000 21.990000 ( 22.002499) | |
GC time: 3.156919999999449s | |
system ~/projects/gc_tests $ (pickjdk 1 ; jruby -v gc_stress.rb) | |
New JDK: 1.6.0.jdk | |
jruby 1.7.0.dev (ruby-1.9.3-p28) (2012-02-19 348601d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java] | |
8.655000 0.000000 8.655000 ( 8.655000) | |
GC time: 0.223s | |
system ~/projects/gc_tests $ (pickjdk 2 ; jruby -v gc_stress.rb) | |
New JDK: 1.6.0_30-b12-409.jdk | |
jruby 1.7.0.dev (ruby-1.9.3-p28) (2012-02-19 348601d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_30) [darwin-x86_64-java] | |
9.354000 0.000000 9.354000 ( 9.354000) | |
GC time: 0.217s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know what tools exist for 1.8.7, but I would guess there might be something in REE?
So...if your results are to be believed, GC is taking more and more time in each major release of Ruby. I hope some of that is being shunted to GC threads (or something), but given that the overall times go up too...it seems like things are moving in the wrong direction.