Sha256: e572fbe0db1feb303a60bce4d1baa2f7f760d141d57a65de6bfd3558a7fedcc7
Contents?: true
Size: 878 Bytes
Versions: 23
Compression:
Stored size: 878 Bytes
Contents
# encoding: utf-8 # This file is distributed under New Relic's license terms. # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details. module Performance class Timer attr_accessor :start_timestamp, :stop_timestamp def initialize @start_timestamp = nil @stop_timestamp = nil end def start(t=Time.now) @start_timestamp = t end def stopped? !!@stop_timestamp end def stop(t=Time.now) @stop_timestamp = t end def measure start yield stop end def elapsed if @stop_timestamp && @start_timestamp @stop_timestamp - @start_timestamp else nil end end def inspect "<Performance::Timer @start_timestamp=#{start_timestamp.inspect}, @stop_timestamp=#{stop_timestamp.inspect}, elapsed=#{elapsed}>" end end end
Version data entries
23 entries across 23 versions & 1 rubygems