Sha256: 3542fd1a734d873cdd8dc2a3beed5c34219ef22e675d3a921e36fd1fb51d8b4b

Contents?: true

Size: 263 Bytes

Versions: 10

Compression:

Stored size: 263 Bytes

Contents

class Time

  # Tracks the elapse time of a code block.
  #
  #   e = Time.elapse { sleep 1 }
  #
  #   e.assert > 1
  #
  # CREDIT: Hal Fulton

  def self.elapse
    raise "Need block" unless block_given?
    t0 = now.to_f
    yield
    now.to_f - t0
  end

end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/time/elapse.rb
facets-3.1.0 lib/core/facets/time/elapse.rb
facets-3.0.0 lib/core/facets/time/elapse.rb
facets-2.9.3 lib/core/facets/time/elapse.rb
facets-2.9.2 src/core/facets/time/elapse.rb
facets-2.9.2 lib/core/facets/time/elapse.rb
facets-2.9.1 lib/core/facets/time/elapse.rb
facets-2.9.0 lib/core/facets/time/elapse.rb
facets-2.9.0.pre.2 lib/core/facets/time/elapse.rb
facets-2.9.0.pre.1 lib/core/facets/time/elapse.rb