Class: Omnizip::Models::ProfileReport

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

Overview

Represents an aggregated profiling report with hot path analysis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile_name:, results: [], hot_paths: [], bottlenecks: [], timestamp: Time.now, metadata: {}) ⇒ ProfileReport

Returns a new instance of ProfileReport.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/omnizip/models/profile_report.rb', line 10

def initialize(
  profile_name:,
  results: [],
  hot_paths: [],
  bottlenecks: [],
  timestamp: Time.now,
  metadata: {}
)
  @profile_name = profile_name
  @results = results
  @hot_paths = hot_paths
  @bottlenecks = bottlenecks
  @timestamp = timestamp
  @metadata = 
end

Instance Attribute Details

#bottlenecksObject (readonly)

Returns the value of attribute bottlenecks.



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

def bottlenecks
  @bottlenecks
end

#hot_pathsObject (readonly)

Returns the value of attribute hot_paths.



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

def hot_paths
  @hot_paths
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

#profile_nameObject (readonly)

Returns the value of attribute profile_name.



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

def profile_name
  @profile_name
end

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

Instance Method Details

#add_bottleneck(bottleneck) ⇒ Object



60
61
62
# File 'lib/omnizip/models/profile_report.rb', line 60

def add_bottleneck(bottleneck)
  @bottlenecks << bottleneck
end

#add_hot_path(hot_path) ⇒ Object



56
57
58
# File 'lib/omnizip/models/profile_report.rb', line 56

def add_hot_path(hot_path)
  @hot_paths << hot_path
end

#add_result(result) ⇒ Object



52
53
54
# File 'lib/omnizip/models/profile_report.rb', line 52

def add_result(result)
  @results << result
end

#memory_intensive_operations(limit: 5) ⇒ Object



45
46
47
48
49
50
# File 'lib/omnizip/models/profile_report.rb', line 45

def memory_intensive_operations(limit: 5)
  results.select(&:memory_allocated)
    .sort_by(&:memory_allocated)
    .reverse
    .take(limit)
end

#slowest_operations(limit: 5) ⇒ Object



38
39
40
41
42
43
# File 'lib/omnizip/models/profile_report.rb', line 38

def slowest_operations(limit: 5)
  results.select(&:total_time)
    .sort_by(&:total_time)
    .reverse
    .take(limit)
end

#to_hObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/omnizip/models/profile_report.rb', line 64

def to_h
  {
    profile_name: profile_name,
    timestamp: timestamp.iso8601,
    summary: {
      total_execution_time: total_execution_time,
      total_memory_allocated: total_memory_allocated,
      total_gc_runs: total_gc_runs,
      operation_count: results.size,
    },
    results: results.map(&:to_h),
    hot_paths: hot_paths,
    bottlenecks: bottlenecks,
    metadata: ,
  }
end

#total_execution_timeObject



26
27
28
# File 'lib/omnizip/models/profile_report.rb', line 26

def total_execution_time
  results.filter_map(&:total_time).sum
end

#total_gc_runsObject



34
35
36
# File 'lib/omnizip/models/profile_report.rb', line 34

def total_gc_runs
  results.filter_map(&:gc_runs).sum
end

#total_memory_allocatedObject



30
31
32
# File 'lib/omnizip/models/profile_report.rb', line 30

def total_memory_allocated
  results.filter_map(&:memory_allocated).sum
end