Sha256: 42ed3caa9b1e320f1f6bba9f2d6bfa1f51ac1d3d27d3bf0378851eefbbf6447b

Contents?: true

Size: 486 Bytes

Versions: 5

Compression:

Stored size: 486 Bytes

Contents

require 'vizsla/recorder'

module Vizsla
  class Timer
    attr_reader :events

    def initialize
      @start_time = nil
      @stop_time = nil
    end

    def start!
      @start_time = Time.now
      Recorder.start_recording
    end

    def stop!
      collect_events
      Recorder.stop_recording
      @stop_time = Time.now
    end

    def collect_events
      @events = Recorder.events
    end

    def elapsed
      "#{(@stop_time - @start_time).round 2}s"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vizsla-0.0.6 lib/vizsla/timer.rb
vizsla-0.0.5 lib/vizsla/timer.rb
vizsla-0.0.4 lib/vizsla/timer.rb
vizsla-0.0.3 lib/vizsla/timer.rb
vizsla-0.0.2 lib/vizsla/timer.rb