Module: Tracebin::Helpers

Included in:
CustomInstrumentation, Event, PatchHelper, Patches, SystemHealthSample, Timer
Defined in:
lib/tracebin/helpers.rb

Instance Method Summary collapse

Instance Method Details

#deserialize_time_string(str) ⇒ Object



15
16
17
# File 'lib/tracebin/helpers.rb', line 15

def deserialize_time_string(str)
  Time.parse(str).in_time_zone('UTC')
end

#milliseconds_between(time1, time2) ⇒ Object



19
20
21
22
23
24
# File 'lib/tracebin/helpers.rb', line 19

def milliseconds_between(time1, time2)
  time1 = deserialize_time_string(time1) if time1.is_a?(String)
  time2 = deserialize_time_string(time2) if time2.is_a?(String)

  to_milliseconds(time1 - time2).abs
end

#time_to_string(time) ⇒ Object



7
8
9
# File 'lib/tracebin/helpers.rb', line 7

def time_to_string(time)
  time.is_a?(String) ? time : time.in_time_zone('UTC').iso8601(6)
end

#timestamp_stringObject



11
12
13
# File 'lib/tracebin/helpers.rb', line 11

def timestamp_string
  Time.now.in_time_zone('UTC').iso8601 6
end

#to_milliseconds(time) ⇒ Object



3
4
5
# File 'lib/tracebin/helpers.rb', line 3

def to_milliseconds(time)
  time.to_f * 1000
end