Skip to content

Instantly share code, notes, and snippets.

@headius
Created January 4, 2012 05:03
Show Gist options
  • Save headius/1558591 to your computer and use it in GitHub Desktop.
Save headius/1558591 to your computer and use it in GitHub Desktop.
system ~/projects/gc_tests $ rvm 1.9.3 do ruby gc_stress.rb
20.760000 0.250000 21.010000 ( 21.007255)
{:count=>7921,
:heap_used=>43,
:heap_length=>43,
:heap_increment=>0,
:heap_live_num=>5607,
:heap_free_num=>11963,
:heap_final_num=>1}
GC time: 2.259033000000017s
system ~/projects/gc_tests $ jruby --1.9 gc_stress.rb
5.270000 0.000000 5.270000 ( 5.270000)
{"PS Scavenge"=>
{:count=>47,
:time=>78,
:pools=>
{"PS Survivor Space"=>
{:committed=>786432,
:init=>3342336,
:max=>786432,
:used=>770064,
:peak_committed=>5767168,
:peak_init=>3342336,
:peak_max=>5767168,
:peak_used=>3386016,
:last_committed=>786432,
:last_init=>3342336,
:last_max=>786432,
:last_used=>770064}}},
"PS MarkSweep"=>
{:count=>0,
:time=>0,
:pools=>
{"PS Perm Gen"=>
{:committed=>21954560,
:init=>21757952,
:max=>85983232,
:used=>21761112,
:peak_committed=>21954560,
:peak_init=>21757952,
:peak_max=>85983232,
:peak_used=>21761112,
:last_committed=>0,
:last_init=>21757952,
:last_max=>85983232,
:last_used=>0}}}}
system ~/projects/gc_tests $ cat gc_stress.rb
require 'benchmark'
case RUBY_ENGINE
when "ruby"
GC::Profiler.enable
end
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
}
require 'pp'
pp GC.stat
case RUBY_ENGINE
when "ruby"
puts "GC time: #{GC::Profiler.total_time}s"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment