Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
GC.measure_total_time=
[T] (T enable) -> T
GC.measure_total_time = setting → setting
gc.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/gc.rb, line 631
def self.measure_total_time=(flag)
Primitive.cstmt! %{
rb_gc_impl_set_measure_total_time(rb_gc_get_objspace(), flag);
return flag;
}
end
Enables or disables GC total time measurement; returns setting. See GC.total_time.
When argument object is nil or false, disables total time measurement; GC.measure_total_time then returns false:
Example
GC.measure_total_time = nil # => nil GC.measure_total_time # => false GC.measure_total_time = false # => false GC.measure_total_time # => false
Otherwise, enables total time measurement; GC.measure_total_time then returns true:
Example
GC.measure_total_time = true # => true GC.measure_total_time # => true GC.measure_total_time = :foo # => :foo GC.measure_total_time # => true
Note that when enabled, total time measurement affects performance.
The setting is per-Ractor: it affects only the Ractor that sets it. With the default GC, a Ractor created by Ractor.new inherits the setting of the Ractor that creates it; the main Ractor starts with measurement enabled.
See also
.measure_total_time
.remove_stress_to_class
.malloc_allocations
.start
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1