Sha256: 06fe1f4ba297b8e7156ba574c88aecf505d13bbec365bf5d9ebae79112757ecd

Contents?: true

Size: 886 Bytes

Versions: 39

Compression:

Stored size: 886 Bytes

Contents

# typed: ignore

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

# TODO: move to Sqreen::Time

module Sqreen
  has_mono_time = begin
    Process.clock_gettime Process::CLOCK_MONOTONIC
    true
  rescue StandardError
    false
  end

  @has_thread_cpu_time = begin
    Process.clock_gettime Process::CLOCK_THREAD_CPUTIME_ID
    true
  rescue StandardError
    false
  end

  class << self
    def thread_cpu_time?
      @has_thread_cpu_time
    end
  end

  if has_mono_time
    def self.time
      Process.clock_gettime Process::CLOCK_MONOTONIC
    end
  else
    def self.time
      Time.now.to_f
    end
  end

  if @has_thread_cpu_time
    def self.thread_cpu_time
      Process.clock_gettime Process::CLOCK_THREAD_CPUTIME_ID
    end
  else
    def self.thread_cpu_time
      0
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
sqreen-1.25.1 lib/sqreen/mono_time.rb
sqreen-1.25.0 lib/sqreen/mono_time.rb
sqreen-1.24.3 lib/sqreen/mono_time.rb
sqreen-1.24.2 lib/sqreen/mono_time.rb
sqreen-1.24.1 lib/sqreen/mono_time.rb
sqreen-1.24.0 lib/sqreen/mono_time.rb
sqreen-1.23.2 lib/sqreen/mono_time.rb
sqreen-1.23.1 lib/sqreen/mono_time.rb
sqreen-1.23.0 lib/sqreen/mono_time.rb
sqreen-1.22.1 lib/sqreen/mono_time.rb
sqreen-1.22.0-java lib/sqreen/mono_time.rb
sqreen-1.22.0 lib/sqreen/mono_time.rb
sqreen-1.21.1-java lib/sqreen/mono_time.rb
sqreen-1.21.1 lib/sqreen/mono_time.rb
sqreen-1.21.0-java lib/sqreen/mono_time.rb
sqreen-1.21.0 lib/sqreen/mono_time.rb
sqreen-1.20.4-java lib/sqreen/mono_time.rb
sqreen-1.20.4 lib/sqreen/mono_time.rb
sqreen-1.21.0.beta3-java lib/sqreen/mono_time.rb
sqreen-1.21.0.beta3 lib/sqreen/mono_time.rb