@@ -383,11 +383,29 @@ def self.latest_gc_info hash_or_key = nil
383383 end
384384
385385 # call-seq:
386- # GC.measure_total_time = true/false
386+ # GC.measure_total_time = setting -> setting
387387 #
388- # Enables measuring \GC time.
389- # You can get the result with <tt>GC.stat(:time)</tt>.
390- # Note that \GC time measurement can cause some performance overhead.
388+ # Enables or disables \GC total time measurement;
389+ # returns +setting+.
390+ # See GC.total_time.
391+ #
392+ # When argument +object+ is +nil+ or +false+, disables total time measurement;
393+ # GC.measure_total_time then returns +false+:
394+ #
395+ # GC.measure_total_time = nil # => nil
396+ # GC.measure_total_time # => false
397+ # GC.measure_total_time = false # => false
398+ # GC.measure_total_time # => false
399+ #
400+ # Otherwise, enables total time measurement;
401+ # GC.measure_total_time then returns +true+:
402+ #
403+ # GC.measure_total_time = true # => true
404+ # GC.measure_total_time # => true
405+ # GC.measure_total_time = :foo # => :foo
406+ # GC.measure_total_time # => true
407+ #
408+ # Note that when enabled, total time measurement affects performance.
391409 def self . measure_total_time = ( flag )
392410 Primitive . cstmt! %{
393411 rb_gc_impl_set_measure_total_time(rb_gc_get_objspace(), flag);
@@ -396,20 +414,47 @@ def self.measure_total_time=(flag)
396414 end
397415
398416 # call-seq:
399- # GC.measure_total_time -> true/ false
417+ # GC.measure_total_time -> true or false
400418 #
401- # Returns the measure_total_time flag (default: +true+).
402- # Note that measurement can affect the application's performance.
419+ # Returns the setting for \GC total time measurement;
420+ # the initial setting is +true+.
421+ # See GC.total_time.
403422 def self . measure_total_time
404423 Primitive . cexpr! %{
405424 RBOOL(rb_gc_impl_get_measure_total_time(rb_gc_get_objspace()))
406425 }
407426 end
408427
409428 # call-seq:
410- # GC.total_time -> int
429+ # GC.total_time -> integer
430+ #
431+ # Returns the \GC total time in nanoseconds:
432+ #
433+ # GC.total_time # => 156250
434+ #
435+ # Note that total time accumulates
436+ # only when total time measurement is enabled
437+ # (that is, when GC.measure_total_time is +true+):
438+ #
439+ # GC.measure_total_time # => true
440+ # GC.total_time # => 625000
441+ # GC.start
442+ # GC.total_time # => 937500
443+ # GC.start
444+ # GC.total_time # => 1093750
445+ #
446+ # GC.measure_total_time = false
447+ # GC.total_time # => 1250000
448+ # GC.start
449+ # GC.total_time # => 1250000
450+ # GC.start
451+ # GC.total_time # => 1250000
452+ #
453+ # GC.measure_total_time = true
454+ # GC.total_time # => 1250000
455+ # GC.start
456+ # GC.total_time # => 1406250
411457 #
412- # Returns the measured \GC total time in nanoseconds.
413458 def self . total_time
414459 Primitive . cexpr! %{
415460 ULL2NUM(rb_gc_impl_get_total_time(rb_gc_get_objspace()))
0 commit comments