Sha256: e9f7fcfdbae62631c1b35a1adc5f5f8b1c31d56cde909732d0ff611d680d5f51

Contents?: true

Size: 359 Bytes

Versions: 1

Compression:

Stored size: 359 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Monitor
    # @api public
    class Clock
      # @api public
      def measure
        start = current
        result = yield
        [result, current - start]
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

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