class Raykit::Timer

Provides functionality to record the time execution times

Attributes

start_time[RW]

The time at which start occurred

Public Class Methods

get_elapsed_str(elapsed,pad=0) click to toggle source

Converts a time span in seconds to a formatted string

# File lib/raykit/timer.rb, line 24
def self.get_elapsed_str(elapsed,pad=0)
    #"[" + "%.0f" % (elapsed) + "s]".ljust(pad)
    "%.0f" % (elapsed) + "s".ljust(pad)
end
new() click to toggle source
# File lib/raykit/timer.rb, line 9
def initialize
    @start_time=Time.now
end

Public Instance Methods

elapsed() click to toggle source

The elapsed time, in seconds, since the timer started

# File lib/raykit/timer.rb, line 14
def elapsed
    return Time.now-@start_time
end
elapsed_str(pad=0) click to toggle source

The elapsed time, in seconds, as a formatted string

# File lib/raykit/timer.rb, line 19
def elapsed_str(pad=0)
    Timer.get_elapsed_str(elapsed,pad)
end