Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem.time
[T] (::String msg, ?::Integer width, ?::boolish display) { () -> T } -> T
time(msg, width = 0, display = Gem.configuration.verbose) { || ... }
lib/rubygems.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems.rb, line 1072
def self.time(msg, width = 0, display = Gem.configuration.verbose)
now = Time.now
value = yield
elapsed = Time.now - now
ui.say format("%2$*1$s: %3$3.3fs", -width, msg, elapsed) if display
value
end
Prints the amount of time the supplied block takes to run using the debug UI output.
See also
.target_rbconfig
.try_activate
.suffix_regexp
.ui
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0