[DOC] Tweaks for GC total time methods
Some checks failed
Windows / Windows 11-arm/Visual C++ (btest test-basic test-tool) (push) Waiting to run
Windows / Windows 2022/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (check) (push) Waiting to run
Windows / Windows 2025/Visual C++ 2022 (test-bundled-gems) (push) Waiting to run
Windows / result (push) Blocked by required conditions
Ubuntu on WSL / wsl (push) Waiting to run
Annocheck / test-annocheck (push) Has been skipped
Cygwin / make (push) Waiting to run
MinGW / (UCRT64) (push) Waiting to run
BASERUBY Check / BASERUBY (push) Has been skipped
parse.y / make (test-bundler-parallel) (push) Has been skipped
Check Dependencies / Dependency checks (push) Failing after 58s
CodeQL / Analyze (push) Has been skipped
Compilations / omnibus compilations, trigger (push) Has been skipped
Misc / Miscellaneous checks (push) Failing after 1m3s
Update default gems list / Update default gems list (push) Has been skipped
parse.y / make (check) (push) Has been skipped
parse.y / make (test-bundled-gems) (push) Has been skipped
WebAssembly / make (map[debugflags: name:O2 optflags:-O2 wasmoptflags:-O2]) (push) Has been skipped
Compilations / omnibus compilations, #1 (push) Has been skipped
Compilations / omnibus compilations, #2 (push) Has been skipped
Compilations / omnibus compilations, #3 (push) Has been skipped
Compilations / omnibus compilations, #4 (push) Has been skipped
Compilations / omnibus compilations, #5 (push) Has been skipped
Compilations / omnibus compilations, #6 (push) Has been skipped
Compilations / omnibus compilations, #7 (push) Has been skipped
Compilations / omnibus compilations, #8 (push) Has been skipped
Compilations / omnibus compilations, #9 (push) Has been skipped
Compilations / omnibus compilations, #10 (push) Has been skipped
Compilations / omnibus compilations, #11 (push) Has been skipped
Compilations / omnibus compilations, #12 (push) Has been skipped
Compilations / omnibus compilations, result (push) Successful in 58s

This commit is contained in:
BurdetteLamar 2025-08-13 13:08:02 -05:00 committed by Peter Zhu
parent 943d9f828d
commit ff622978d0

63
gc.rb
View file

@ -383,11 +383,29 @@ module GC
end end
# call-seq: # call-seq:
# GC.measure_total_time = true/false # GC.measure_total_time = setting -> setting
# #
# Enables measuring \GC time. # Enables or disables \GC total time measurement;
# You can get the result with <tt>GC.stat(:time)</tt>. # returns +setting+.
# Note that \GC time measurement can cause some performance overhead. # See GC.total_time.
#
# When argument +object+ is +nil+ or +false+, disables total time measurement;
# GC.measure_total_time then returns +false+:
#
# 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+:
#
# 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.
def self.measure_total_time=(flag) def self.measure_total_time=(flag)
Primitive.cstmt! %{ Primitive.cstmt! %{
rb_gc_impl_set_measure_total_time(rb_gc_get_objspace(), flag); rb_gc_impl_set_measure_total_time(rb_gc_get_objspace(), flag);
@ -396,10 +414,11 @@ module GC
end end
# call-seq: # call-seq:
# GC.measure_total_time -> true/false # GC.measure_total_time -> true or false
# #
# Returns the measure_total_time flag (default: +true+). # Returns the setting for \GC total time measurement;
# Note that measurement can affect the application's performance. # the initial setting is +true+.
# See GC.total_time.
def self.measure_total_time def self.measure_total_time
Primitive.cexpr! %{ Primitive.cexpr! %{
RBOOL(rb_gc_impl_get_measure_total_time(rb_gc_get_objspace())) RBOOL(rb_gc_impl_get_measure_total_time(rb_gc_get_objspace()))
@ -407,9 +426,35 @@ module GC
end end
# call-seq: # call-seq:
# GC.total_time -> int # GC.total_time -> integer
#
# Returns the \GC total time in nanoseconds:
#
# GC.total_time # => 156250
#
# Note that total time accumulates
# only when total time measurement is enabled
# (that is, when GC.measure_total_time is +true+):
#
# GC.measure_total_time # => true
# GC.total_time # => 625000
# GC.start
# GC.total_time # => 937500
# GC.start
# GC.total_time # => 1093750
#
# GC.measure_total_time = false
# GC.total_time # => 1250000
# GC.start
# GC.total_time # => 1250000
# GC.start
# GC.total_time # => 1250000
#
# GC.measure_total_time = true
# GC.total_time # => 1250000
# GC.start
# GC.total_time # => 1406250
# #
# Returns the measured \GC total time in nanoseconds.
def self.total_time def self.total_time
Primitive.cexpr! %{ Primitive.cexpr! %{
ULL2NUM(rb_gc_impl_get_total_time(rb_gc_get_objspace())) ULL2NUM(rb_gc_impl_get_total_time(rb_gc_get_objspace()))