Sha256: deb2b732cdf6fbbb9fd93a850395ed186346c677ee3c8c6c3937ed855f03ee69

Contents?: true

Size: 394 Bytes

Versions: 10

Compression:

Stored size: 394 Bytes

Contents

module HelperClasses
  class Timing
    def initialize(dbg = 0)
      @dbg_lvl = dbg
      @time = Time.now
    end

    def probe(msg = '')
      t = sprintf('%6f', (Time.now - @time).to_f)
      dputs(@dbg_lvl) { "#{msg}: #{t}" }
      @time = Time.now
    end

    def self.measure(msg = '', dbg = 0)
      t = Timing.new(dbg)
      ret = yield
      t.probe(msg)
      ret
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
helper_classes-1.9.1312 lib/helper_classes/timing.rb
helper_classes-1.9.13.pre.12 lib/helper_classes/timing.rb
helper_classes-1.9.13.pre.11 lib/helper_classes/timing.rb
helper_classes-1.9.13.pre.10 lib/helper_classes/timing.rb
helper_classes-0.3.5 lib/helper_classes/timing.rb
helper_classes-0.3.1 lib/helper_classes/timing.rb
helper_classes-0.3.0 lib/helper_classes/timing.rb
helper_classes-0.2.1 lib/helperclasses/timing.rb
HelperClasses-0.2.1 lib/helperclasses/timing.rb
HelperClasses-0.2.0 lib/helperclasses/timing.rb