Sha256: 7cca8c8093707dabe836126d3ff10ce818086f3a88f15791de00e41009d1add1

Contents?: true

Size: 446 Bytes

Versions: 1

Compression:

Stored size: 446 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Monitor
    # @api public
    class Clock
      # @api private
      def initialize(unit: :millisecond)
        @unit = unit
      end

      # @api public
      def measure
        start = current
        result = yield
        [result, current - start]
      end

      # @api public
      def current
        Process.clock_gettime(Process::CLOCK_MONOTONIC, @unit)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-monitor-1.0.1 lib/dry/monitor/clock.rb