Class: Omnizip::Models::ProfileReport
- Inherits:
-
Object
- Object
- Omnizip::Models::ProfileReport
- Defined in:
- lib/omnizip/models/profile_report.rb
Overview
Represents an aggregated profiling report with hot path analysis
Instance Attribute Summary collapse
-
#bottlenecks ⇒ Object
readonly
Returns the value of attribute bottlenecks.
-
#hot_paths ⇒ Object
readonly
Returns the value of attribute hot_paths.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#profile_name ⇒ Object
readonly
Returns the value of attribute profile_name.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #add_bottleneck(bottleneck) ⇒ Object
- #add_hot_path(hot_path) ⇒ Object
- #add_result(result) ⇒ Object
-
#initialize(profile_name:, results: [], hot_paths: [], bottlenecks: [], timestamp: Time.now, metadata: {}) ⇒ ProfileReport
constructor
A new instance of ProfileReport.
- #memory_intensive_operations(limit: 5) ⇒ Object
- #slowest_operations(limit: 5) ⇒ Object
- #to_h ⇒ Object
- #total_execution_time ⇒ Object
- #total_gc_runs ⇒ Object
- #total_memory_allocated ⇒ Object
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 = @metadata = end |
Instance Attribute Details
#bottlenecks ⇒ Object (readonly)
Returns the value of attribute bottlenecks.
7 8 9 |
# File 'lib/omnizip/models/profile_report.rb', line 7 def bottlenecks @bottlenecks end |
#hot_paths ⇒ Object (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 |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/omnizip/models/profile_report.rb', line 7 def @metadata end |
#profile_name ⇒ Object (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 |
#results ⇒ Object (readonly)
Returns the value of attribute results.
7 8 9 |
# File 'lib/omnizip/models/profile_report.rb', line 7 def results @results end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/omnizip/models/profile_report.rb', line 7 def @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_h ⇒ Object
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: .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_time ⇒ Object
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_runs ⇒ Object
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_allocated ⇒ Object
30 31 32 |
# File 'lib/omnizip/models/profile_report.rb', line 30 def total_memory_allocated results.filter_map(&:memory_allocated).sum end |