Module: GCTime::Backport

Included in:
GCTime
Defined in:
lib/gctime.rb,
lib/gctime.rb

Overview

We’re likely on JRuby or TruffleRuby

Constant Summary collapse

UNDEF =
BasicObject.new

Instance Method Summary collapse

Instance Method Details

#measure_total_timeObject



10
11
12
# File 'lib/gctime.rb', line 10

def measure_total_time
  true
end

#measure_total_time=(enabled) ⇒ Object



14
15
16
# File 'lib/gctime.rb', line 14

def measure_total_time=(enabled)
  # noop
end

#stat(key = UNDEF) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gctime.rb', line 34

def stat(key = UNDEF)
  if UNDEF.equal?(key)
    stats = super()
    stats[:time] = ::GCTime._time_ms # milliseconds integer
    stats
  elsif key == :time
    ::GCTime._time_ms # milliseconds integer
  elsif Hash === key
    stats = super
    stats[:time] = ::GCTime._time_ms # milliseconds integer
    stats
  else
    super
  end
end

#total_timeObject



18
19
20
# File 'lib/gctime.rb', line 18

def total_time
  stat(:time) * 1_000_000 # nanoseconds integer
end