Sha256: 489397dda0af9dda7d7914001317cff3b1cab8e4d02b0a5d54306ee1828351c9

Contents?: true

Size: 374 Bytes

Versions: 6

Compression:

Stored size: 374 Bytes

Contents

#
# This file defines a $log variable for logging, and a time() method for recording timing
# information.
#

$log = Object.new
def $log.debug(str)
  STDERR.puts str
end

def time(msg, width=25)
  t = Time.now
  return_value = yield
  elapsed = Time.now.to_f - t.to_f
  elapsed = sprintf("%3.3f", elapsed)
  $log.debug "#{msg.ljust(width)}: #{elapsed}s"
  return_value
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubygems-update-0.8.4 lib/rubygems/timer.rb
rubygems-update-0.8.6 lib/rubygems/timer.rb
rubygems-update-0.8.8 lib/rubygems/timer.rb
rubygems-update-0.8.11 lib/rubygems/timer.rb
rubygems-update-0.8.10 lib/rubygems/timer.rb
rubygems-update-0.8.5 lib/rubygems/timer.rb