Class: Omnizip::Models::PerformanceResult

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/models/performance_result.rb

Overview

Represents the performance characteristics of a profiled operation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation_name:, total_time: nil, cpu_time: nil, wall_time: nil, memory_allocated: nil, memory_retained: nil, object_allocations: nil, gc_runs: nil, call_count: nil, timestamp: Time.now) ⇒ PerformanceResult

Returns a new instance of PerformanceResult.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omnizip/models/performance_result.rb', line 11

def initialize(
  operation_name:,
  total_time: nil,
  cpu_time: nil,
  wall_time: nil,
  memory_allocated: nil,
  memory_retained: nil,
  object_allocations: nil,
  gc_runs: nil,
  call_count: nil,
  timestamp: Time.now
)
  @operation_name = operation_name
  @total_time = total_time
  @cpu_time = cpu_time
  @wall_time = wall_time
  @memory_allocated = memory_allocated
  @memory_retained = memory_retained
  @object_allocations = object_allocations
  @gc_runs = gc_runs
  @call_count = call_count
  @timestamp = timestamp
end

Instance Attribute Details

#call_countObject (readonly)

Returns the value of attribute call_count.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def call_count
  @call_count
end

#cpu_timeObject (readonly)

Returns the value of attribute cpu_time.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def cpu_time
  @cpu_time
end

#gc_runsObject (readonly)

Returns the value of attribute gc_runs.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def gc_runs
  @gc_runs
end

#memory_allocatedObject (readonly)

Returns the value of attribute memory_allocated.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def memory_allocated
  @memory_allocated
end

#memory_retainedObject (readonly)

Returns the value of attribute memory_retained.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def memory_retained
  @memory_retained
end

#object_allocationsObject (readonly)

Returns the value of attribute object_allocations.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def object_allocations
  @object_allocations
end

#operation_nameObject (readonly)

Returns the value of attribute operation_name.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def operation_name
  @operation_name
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def timestamp
  @timestamp
end

#total_timeObject (readonly)

Returns the value of attribute total_time.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def total_time
  @total_time
end

#wall_timeObject (readonly)

Returns the value of attribute wall_time.



7
8
9
# File 'lib/omnizip/models/performance_result.rb', line 7

def wall_time
  @wall_time
end

Instance Method Details

#average_time_per_operationObject



41
42
43
44
45
# File 'lib/omnizip/models/performance_result.rb', line 41

def average_time_per_operation
  return nil unless call_count && total_time && call_count.positive?

  total_time / call_count.to_f
end

#gc_pressureObject



53
54
55
56
57
# File 'lib/omnizip/models/performance_result.rb', line 53

def gc_pressure
  return nil unless gc_runs && total_time&.positive?

  gc_runs.to_f / total_time
end

#memory_per_operationObject



47
48
49
50
51
# File 'lib/omnizip/models/performance_result.rb', line 47

def memory_per_operation
  return nil unless call_count && memory_allocated && call_count.positive?

  memory_allocated / call_count.to_f
end

#throughput_ops_per_secondObject



35
36
37
38
39
# File 'lib/omnizip/models/performance_result.rb', line 35

def throughput_ops_per_second
  return nil unless call_count && total_time&.positive?

  call_count.to_f / total_time
end

#to_hObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/omnizip/models/performance_result.rb', line 59

def to_h
  {
    operation_name: operation_name,
    total_time: total_time,
    cpu_time: cpu_time,
    wall_time: wall_time,
    memory_allocated: memory_allocated,
    memory_retained: memory_retained,
    object_allocations: object_allocations,
    gc_runs: gc_runs,
    call_count: call_count,
    throughput_ops_per_second: throughput_ops_per_second,
    average_time_per_operation: average_time_per_operation,
    memory_per_operation: memory_per_operation,
    gc_pressure: gc_pressure,
    timestamp: timestamp.iso8601,
  }
end