Sha256: ea6876194235b2c24c9fa00691b77e83319008d2ca78a042328423edcf72d007

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 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
      attr_reader :start_ms, :events

      def initialize time = Time.now
        @start_at = time
        @start_ms = (@start_at.to_f * 1000).to_i
        @events = {}
      end

      def self.now_ms
        (Time.now.to_f * 1000).to_i
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-6.1.2 lib/contrast/utils/timer.rb
contrast-agent-6.1.1 lib/contrast/utils/timer.rb