summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRian McGuire <rian@rian.id.au>2024-01-06 16:02:36 +1100
committerKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2024-01-06 17:36:35 +1100
commit913b26d0fd7ad5dafe3d613ccd5494dab6771962 (patch)
tree621ba8f09c97f6a27ad29fdfb14bae02b2f1820c
parent7db35e10c37f5662d5c41d1d73ffdc5948f6dd2a (diff)
Add test case for GC.measure_total_time
-rw-r--r--test/ruby/test_gc.rb17
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