public
Last active

  • Download Gist
gc-test-ruby-1.8.rb
Ruby
1 2 3 4 5 6 7 8 9
count = ObjectSpace.each_object { }
100_000.times do |i|
String.new
c = ObjectSpace.each_object { }
if c < count
puts "GC - Iteration #{i} - Was #{count} now #{c}"
end
count = c
end
gc-test-ruby-1.9.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# too bad this didnt make it into 1.9 (Object#tap did)
class Object
def returning(&block)
return yield(self)
end
end
 
count = ObjectSpace.count_objects.returning { |h| h[:TOTAL] - h[:FREE] }
100_000.times do |i|
String.new
c = ObjectSpace.count_objects.returning { |h| h[:TOTAL] - h[:FREE] }
if c < count
puts "GC - Iteration #{i} - Was #{count} now #{c}"
end
count = c
end
results-irb-ruby-1.8.6.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
(code with "puts Time.now" at beginning and end was pasted in)
 
>> puts Time.now
Sun Feb 15 15:44:38 -0500 2009
=> nil
>> count = ObjectSpace.each_object { }
=> 7930
>> 100_000.times do |i|
?> String.new
>> c = ObjectSpace.each_object { }
>> if c < count
>> puts "GC - Iteration #{i} - Was #{count} now #{c}"
>> end
>> count = c
>> end
GC - Iteration 14738 - Was 24489 now 5272
GC - Iteration 31811 - Was 22348 now 5273
GC - Iteration 48884 - Was 22349 now 5274
GC - Iteration 65956 - Was 22349 now 5273
GC - Iteration 83029 - Was 22349 now 5273
=> 100000
>> puts Time.now
Sun Feb 15 15:46:52 -0500 2009
=> nil
 
(note that this took about 2.5 minutes!)
results-ruby-1.8.6.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
GC - Iteration 1640 - Was 1960 now 312
GC - Iteration 3281 - Was 1956 now 314
GC - Iteration 4921 - Was 1957 now 313
GC - Iteration 6562 - Was 1957 now 314
GC - Iteration 8202 - Was 1957 now 314
GC - Iteration 9842 - Was 1957 now 314
GC - Iteration 11482 - Was 1957 now 314
GC - Iteration 13122 - Was 1957 now 315
GC - Iteration 14762 - Was 1958 now 315
GC - Iteration 16402 - Was 1958 now 314
GC - Iteration 18042 - Was 1957 now 313
GC - Iteration 19683 - Was 1957 now 314
GC - Iteration 21323 - Was 1957 now 314
GC - Iteration 22963 - Was 1957 now 314
GC - Iteration 24603 - Was 1957 now 314
GC - Iteration 26243 - Was 1957 now 314
GC - Iteration 27883 - Was 1957 now 314
GC - Iteration 29523 - Was 1957 now 314
GC - Iteration 31163 - Was 1957 now 314
GC - Iteration 32803 - Was 1957 now 314
GC - Iteration 34443 - Was 1957 now 314
GC - Iteration 36083 - Was 1957 now 314
GC - Iteration 37723 - Was 1957 now 314
GC - Iteration 39363 - Was 1957 now 314
GC - Iteration 41003 - Was 1957 now 314
GC - Iteration 42643 - Was 1957 now 314
GC - Iteration 44283 - Was 1957 now 314
GC - Iteration 45923 - Was 1957 now 314
GC - Iteration 47563 - Was 1957 now 314
GC - Iteration 49203 - Was 1957 now 314
GC - Iteration 50843 - Was 1957 now 314
GC - Iteration 52483 - Was 1957 now 314
GC - Iteration 54123 - Was 1957 now 314
GC - Iteration 55763 - Was 1957 now 314
GC - Iteration 57403 - Was 1957 now 314
GC - Iteration 59043 - Was 1957 now 314
GC - Iteration 60683 - Was 1957 now 314
GC - Iteration 62323 - Was 1957 now 314
GC - Iteration 63963 - Was 1957 now 314
GC - Iteration 65603 - Was 1957 now 314
GC - Iteration 67243 - Was 1957 now 314
GC - Iteration 68883 - Was 1957 now 314
GC - Iteration 70523 - Was 1957 now 314
GC - Iteration 72163 - Was 1957 now 314
GC - Iteration 73803 - Was 1957 now 314
GC - Iteration 75443 - Was 1957 now 314
GC - Iteration 77083 - Was 1957 now 314
GC - Iteration 78723 - Was 1957 now 314
GC - Iteration 80363 - Was 1957 now 314
GC - Iteration 82003 - Was 1957 now 314
GC - Iteration 83643 - Was 1957 now 314
GC - Iteration 85283 - Was 1957 now 314
GC - Iteration 86923 - Was 1957 now 314
GC - Iteration 88563 - Was 1957 now 314
GC - Iteration 90203 - Was 1957 now 314
GC - Iteration 91843 - Was 1957 now 314
GC - Iteration 93483 - Was 1957 now 314
GC - Iteration 95123 - Was 1957 now 314
GC - Iteration 96763 - Was 1957 now 314
GC - Iteration 98403 - Was 1957 now 314
 
real 0m10.183s
user 0m10.173s
sys 0m0.009s
results-ruby-1.9.1-running-ruby-1.8-code.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
GC - Iteration 7443 - Was 9698 now 2036
GC - Iteration 16345 - Was 10944 now 2042
GC - Iteration 25242 - Was 10944 now 2042
GC - Iteration 34139 - Was 10944 now 2042
GC - Iteration 43036 - Was 10944 now 2042
GC - Iteration 51933 - Was 10944 now 2042
GC - Iteration 60830 - Was 10944 now 2042
GC - Iteration 69727 - Was 10944 now 2042
GC - Iteration 78624 - Was 10944 now 2042
GC - Iteration 87521 - Was 10944 now 2042
GC - Iteration 96418 - Was 10944 now 2042
 
real 1m1.231s
user 1m1.204s
sys 0m0.078s
results-ruby-1.9.1-running-ruby-1.9-code.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
GC - Iteration 1837 - Was 17185 now 8373
GC - Iteration 4039 - Was 17184 now 8379
GC - Iteration 6240 - Was 17185 now 8379
GC - Iteration 8441 - Was 17185 now 8376
GC - Iteration 10643 - Was 17186 now 8377
GC - Iteration 12845 - Was 17187 now 8372
GC - Iteration 15048 - Was 17186 now 8373
GC - Iteration 17251 - Was 17187 now 8376
GC - Iteration 19453 - Was 17186 now 8375
GC - Iteration 21655 - Was 17185 now 8375
GC - Iteration 23857 - Was 17185 now 8372
GC - Iteration 26060 - Was 17186 now 8371
GC - Iteration 28263 - Was 17185 now 8373
GC - Iteration 30466 - Was 17187 now 8374
GC - Iteration 32668 - Was 17184 now 8376
GC - Iteration 34870 - Was 17186 now 8375
GC - Iteration 37072 - Was 17185 now 8377
GC - Iteration 39274 - Was 17187 now 8374
GC - Iteration 41476 - Was 17184 now 8373
GC - Iteration 43679 - Was 17187 now 8378
GC - Iteration 45880 - Was 17184 now 8376
GC - Iteration 48082 - Was 17186 now 8371
GC - Iteration 50285 - Was 17185 now 8373
GC - Iteration 52488 - Was 17187 now 8374
GC - Iteration 54690 - Was 17184 now 8372
GC - Iteration 56893 - Was 17186 now 8372
GC - Iteration 59096 - Was 17186 now 8376
GC - Iteration 61298 - Was 17186 now 8375
GC - Iteration 63500 - Was 17185 now 8375
GC - Iteration 65702 - Was 17185 now 8371
GC - Iteration 67905 - Was 17185 now 8370
GC - Iteration 70108 - Was 17184 now 8371
GC - Iteration 72311 - Was 17185 now 8371
GC - Iteration 74514 - Was 17185 now 8370
GC - Iteration 76717 - Was 17184 now 8373
GC - Iteration 78920 - Was 17187 now 8378
GC - Iteration 81121 - Was 17184 now 8375
GC - Iteration 83323 - Was 17185 now 8372
GC - Iteration 85526 - Was 17186 now 8372
GC - Iteration 87729 - Was 17186 now 8375
GC - Iteration 89931 - Was 17185 now 8372
GC - Iteration 92134 - Was 17186 now 8373
GC - Iteration 94337 - Was 17187 now 8378
GC - Iteration 96538 - Was 17184 now 8376
GC - Iteration 98740 - Was 17186 now 8374
 
real 0m4.272s
user 0m4.264s
sys 0m0.012s
results-textmate.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
GC - Iteration 384 - Was 1950 now 423
GC - Iteration 5746 - Was 5788 now 425
GC - Iteration 11109 - Was 5791 now 427
GC - Iteration 16471 - Was 5792 now 426
GC - Iteration 21833 - Was 5791 now 426
GC - Iteration 27195 - Was 5791 now 426
GC - Iteration 32557 - Was 5791 now 426
GC - Iteration 37919 - Was 5791 now 426
GC - Iteration 43281 - Was 5791 now 426
GC - Iteration 48643 - Was 5791 now 426
GC - Iteration 54005 - Was 5791 now 426
GC - Iteration 59367 - Was 5791 now 426
GC - Iteration 64729 - Was 5791 now 426
GC - Iteration 70091 - Was 5791 now 426
GC - Iteration 75453 - Was 5791 now 426
GC - Iteration 80815 - Was 5791 now 426
GC - Iteration 86177 - Was 5791 now 426
GC - Iteration 91539 - Was 5791 now 427
GC - Iteration 96900 - Was 5791 now 425
 
(Program exited with code #0 after 26.87 seconds.)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.