Sha256: 30d4bfd45161dd9fa1746ea8c540eddf0103892a4e1ad82be69c257d90594dfd

Contents?: true

Size: 872 Bytes

Versions: 181

Compression:

Stored size: 872 Bytes

Contents

require 'timecop'

module Process
  class << self
    alias_method :clock_gettime_original, :clock_gettime

    def clock_gettime(clock_id, unit = :float_second)
      # now only support CLOCK_REALTIME
      if Process::CLOCK_REALTIME == clock_id
        t = Time.now

        case unit
        when :float_second
          t.to_i + t.nsec / 1_000_000_000.0
        when :float_millisecond
          t.to_i * 1_000 + t.nsec / 1_000_000.0
        when :float_microsecond
          t.to_i * 1_000_000 + t.nsec / 1_000.0
        when :second
          t.to_i
        when :millisecond
          t.to_i * 1000 + t.nsec / 1_000_000
        when :microsecond
          t.to_i * 1_000_000 + t.nsec / 1_000
        when :nanosecond
          t.to_i * 1_000_000_000 + t.nsec
        end
      else
        Process.clock_gettime_original(clock_id, unit)
      end
    end
  end
end

Version data entries

181 entries across 181 versions & 7 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/helpers/process_extenstion.rb
fluentd-1.16.6-x86-mingw32 test/helpers/process_extenstion.rb
fluentd-1.16.6-x64-mingw32 test/helpers/process_extenstion.rb
fluentd-1.16.6-x64-mingw-ucrt test/helpers/process_extenstion.rb
fluentd-1.16.6 test/helpers/process_extenstion.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/helpers/process_extenstion.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/helpers/process_extenstion.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/helpers/process_extenstion.rb
fluentd-1.17.0-x86-mingw32 test/helpers/process_extenstion.rb
fluentd-1.17.0-x64-mingw-ucrt test/helpers/process_extenstion.rb
fluentd-1.17.0-x64-mingw32 test/helpers/process_extenstion.rb
fluentd-1.17.0 test/helpers/process_extenstion.rb
fluentd-1.16.5-x64-mingw-ucrt test/helpers/process_extenstion.rb
fluentd-1.16.5-x86-mingw32 test/helpers/process_extenstion.rb
fluentd-1.16.5-x64-mingw32 test/helpers/process_extenstion.rb
fluentd-1.16.5 test/helpers/process_extenstion.rb
fluentd-1.16.4-x64-mingw-ucrt test/helpers/process_extenstion.rb
fluentd-1.16.4-x86-mingw32 test/helpers/process_extenstion.rb
fluentd-1.16.4-x64-mingw32 test/helpers/process_extenstion.rb
fluentd-1.16.4 test/helpers/process_extenstion.rb