Sha256: bc9b79a1a96452c83549e5476f1b843a7f804aa905341f544d79fd00a5d2ea17

Contents?: true

Size: 812 Bytes

Versions: 13

Compression:

Stored size: 812 Bytes

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Utils
    # Timer is class that can track state about when an event starts and how long it takes
    # Also contains utility methods to get time values in milliseconds
    class Timer
      # @return [Integer] the ms of the Time that this instance represents
      attr_reader :start_ms

      # Create a wrapper for the current time
      #
      # @param time [Time]
      def initialize time = Time.now
        @start_at = time
        @start_ms = (@start_at.to_f * 1000).to_i
        @events = {}
      end

      # @return [Integer] time, in ms
      def self.now_ms
        (Time.now.to_f * 1000).to_i
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
contrast-agent-6.8.0 lib/contrast/utils/timer.rb
contrast-agent-6.7.0 lib/contrast/utils/timer.rb
contrast-agent-6.6.5 lib/contrast/utils/timer.rb
contrast-agent-6.6.4 lib/contrast/utils/timer.rb
contrast-agent-6.6.3 lib/contrast/utils/timer.rb
contrast-agent-6.6.2 lib/contrast/utils/timer.rb
contrast-agent-6.6.1 lib/contrast/utils/timer.rb
contrast-agent-6.6.0 lib/contrast/utils/timer.rb
contrast-agent-6.5.1 lib/contrast/utils/timer.rb
contrast-agent-6.5.0 lib/contrast/utils/timer.rb
contrast-agent-6.4.0 lib/contrast/utils/timer.rb
contrast-agent-6.3.0 lib/contrast/utils/timer.rb
contrast-agent-6.2.0 lib/contrast/utils/timer.rb