diff options
author | KJ Tsanaktsidis <[email protected]> | 2024-02-01 15:33:30 +1100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-02-01 04:33:30 +0000 |
commit | 920c17dc94239baae05b513046b27967f11a3569 (patch) | |
tree | abf5dfb7e724c164619649757375faf109975edb /test/ruby | |
parent | 2886564279dff87a6c293f6e80436eb2b309967e (diff) |
Backport #20157 to Ruby 3.3 (#9428)
* Fix GC.measure_total_time regression
Commit 93ac7405b80cc61930d73da04441fa09af1851e1 introduced a regression
where measurements would still be taken after setting
GC.measure_total_time = false.
Fixes [Bug #20157]
* Add test case for GC.measure_total_time
---------
Co-authored-by: Rian McGuire <[email protected]>
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_gc.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 4c4a7f6a27..39b001c3d0 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -231,6 +231,23 @@ class TestGc < Test::Unit::TestCase assert_equal stat[:total_freed_objects], stat_heap_sum[:total_freed_objects] end + def test_measure_total_time + assert_separately([], __FILE__, __LINE__, <<~RUBY) + GC.measure_total_time = false + + time_before = GC.stat(:time) + + # Generate some garbage + Random.new.bytes(100 * 1024 * 1024) + GC.start + + time_after = GC.stat(:time) + + # If time measurement is disabled, the time stat should not change + assert_equal time_before, time_after + RUBY + end + def test_latest_gc_info omit 'stress' if GC.stress |