Class: TimeMethod::Measurement

Inherits:
Object
  • Object
show all
Defined in:
lib/time_method/measurement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass_name:, method_name:, t0:, t1:) ⇒ Measurement

Returns a new instance of Measurement.



4
5
6
7
8
9
10
11
12
# File 'lib/time_method/measurement.rb', line 4

def initialize(klass_name:, method_name:, t0:, t1:)
  @klass_name  = klass_name
  @method_name = method_name
  @t0          = t0
  @t1          = t1
  # @time        = runtime_ms
  @time        = runtime_seconds
  store_measurement
end

Instance Attribute Details

#klass_nameObject

Returns the value of attribute klass_name.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def klass_name
  @klass_name
end

#metadataObject

Returns the value of attribute metadata.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def 
  @metadata
end

#method_nameObject

Returns the value of attribute method_name.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def method_name
  @method_name
end

#segmentObject

Returns the value of attribute segment.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def segment
  @segment
end

#t0Object

Returns the value of attribute t0.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def t0
  @t0
end

#t1Object

Returns the value of attribute t1.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def t1
  @t1
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/time_method/measurement.rb', line 3

def time
  @time
end

Instance Method Details

#output_stackObject



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

def output_stack
  StoreMeasurement.instance.output_stack
end

#runtimeObject



22
23
24
# File 'lib/time_method/measurement.rb', line 22

def runtime
  @runtime_in_milliseconds ||= ((@t1 - @t0) * 1000).round(2)
end

#runtime_msObject



26
27
28
# File 'lib/time_method/measurement.rb', line 26

def runtime_ms
  @runtime_in_milliseconds ||= ((@t1 - @t0) * 1000).round(2)
end

#runtime_secondsObject



30
31
32
# File 'lib/time_method/measurement.rb', line 30

def runtime_seconds
  @runtime_in_seconds ||= (@t1 - @t0).round(2)
end

#store_measurementObject



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

def store_measurement
  StoreMeasurement.instance.store(klass_name:@klass_name,method_name:@method_name,time:@time)
end