Sha256: 6c4cb43215f0a0af57d61af479e2f0a15884c7d11e08940703975fa8fdb1e28a

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

require "securerandom" unless defined?(SecureRandom)

module Lite
  module Command
    module Internals
      module Runtimes

        def index
          @index ||= context.index ||= 0
        end

        def cmd_id
          @cmd_id ||= context.cmd_id ||= SecureRandom.uuid
        end

        private

        def assign_execution_cmd_id
          @cmd_id = context.cmd_id ||= cmd_id
        end

        def increment_execution_index
          @index = context.index = index.next
        end

        def start_monotonic_time
          @start_monotonic_time ||= Utils.monotonic_time
        end

        def stop_monotonic_time
          @stop_monotonic_time ||= Utils.monotonic_time
        end

        def runtime
          return unless executed?

          stop_monotonic_time - start_monotonic_time
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lite-command-3.3.3 lib/lite/command/internals/runtimes.rb
lite-command-3.3.2 lib/lite/command/internals/runtimes.rb
lite-command-3.3.1 lib/lite/command/internals/runtimes.rb
lite-command-3.3.0 lib/lite/command/internals/runtimes.rb