aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-08-16 13:54:55 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-08-17 15:53:00 -0400
commit52506cbf516da1a606fad6a6779ab6136c4f353b (patch)
tree15392bfac4a32c99b34142bf8743045eb98f3eaf /test
parent818998b41b41a4f2f4120b0a0b6a92e4009ee5ba (diff)
downloadruby-52506cbf516da1a606fad6a6779ab6136c4f353b.tar.gz
Move total_allocated_objects to size pool
This commit moves the `total_allocated_objects` statistic to the size pool which allows for `total_allocated_objects` key in `GC.stat_heap`.
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_gc.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index aabdfc0cf8..7513aca46d 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -164,6 +164,7 @@ class TestGc < Test::Unit::TestCase
assert_operator stat_heap[:total_freed_pages], :>=, 0
assert_operator stat_heap[:force_major_gc_count], :>=, 0
assert_operator stat_heap[:force_incremental_marking_finish_count], :>=, 0
+ assert_operator stat_heap[:total_allocated_objects], :>=, 0
end
GC.stat_heap(0, stat_heap)
@@ -186,6 +187,11 @@ class TestGc < Test::Unit::TestCase
GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT].times do |i|
GC.stat_heap(i, stat_heap)
+ # Remove keys that can vary between invocations
+ %i(total_allocated_objects).each do |sym|
+ stat_heap[sym] = stat_heap_all[i][sym] = 0
+ end
+
assert_equal stat_heap, stat_heap_all[i]
end
@@ -197,8 +203,10 @@ class TestGc < Test::Unit::TestCase
stat = GC.stat
stat_heap = GC.stat_heap
- GC.stat(stat)
- GC.stat_heap(nil, stat_heap)
+ 2.times do
+ GC.stat(stat)
+ GC.stat_heap(nil, stat_heap)
+ end
stat_heap_sum = Hash.new(0)
stat_heap.values.each do |hash|
@@ -211,6 +219,7 @@ class TestGc < Test::Unit::TestCase
assert_equal stat[:heap_available_slots], stat_heap_sum[:heap_eden_slots] + stat_heap_sum[:heap_tomb_slots]
assert_equal stat[:total_allocated_pages], stat_heap_sum[:total_allocated_pages]
assert_equal stat[:total_freed_pages], stat_heap_sum[:total_freed_pages]
+ assert_equal stat[:total_allocated_objects], stat_heap_sum[:total_allocated_objects]
end
def test_latest_gc_info