Class: RegoValidate::Profiler::Delta
- Inherits:
-
Object
- Object
- RegoValidate::Profiler::Delta
- Defined in:
- lib/ruby/rego/cli/profiling.rb
Overview
Computes deltas between snapshots.
Constant Summary collapse
- SKIP_KEYS =
%i[TOTAL FREE].freeze
Instance Attribute Summary collapse
-
#allocations ⇒ Object
readonly
Returns the value of attribute allocations.
-
#memory_bytes ⇒ Object
readonly
Returns the value of attribute memory_bytes.
-
#object_deltas ⇒ Object
readonly
Returns the value of attribute object_deltas.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(allocations:, memory_bytes:, object_deltas:) ⇒ Delta
constructor
A new instance of Delta.
-
#top_objects(limit: 3) ⇒ Object
Constructor Details
#initialize(allocations:, memory_bytes:, object_deltas:) ⇒ Delta
Returns a new instance of Delta.
134 135 136 137 138 |
# File 'lib/ruby/rego/cli/profiling.rb', line 134 def initialize(allocations:, memory_bytes:, object_deltas:) @allocations = allocations @memory_bytes = memory_bytes @object_deltas = object_deltas end |
Instance Attribute Details
#allocations ⇒ Object (readonly)
Returns the value of attribute allocations.
140 141 142 |
# File 'lib/ruby/rego/cli/profiling.rb', line 140 def allocations @allocations end |
#memory_bytes ⇒ Object (readonly)
Returns the value of attribute memory_bytes.
140 141 142 |
# File 'lib/ruby/rego/cli/profiling.rb', line 140 def memory_bytes @memory_bytes end |
#object_deltas ⇒ Object (readonly)
Returns the value of attribute object_deltas.
140 141 142 |
# File 'lib/ruby/rego/cli/profiling.rb', line 140 def object_deltas @object_deltas end |
Class Method Details
.skip_key?(key) ⇒ Boolean
130 131 132 |
# File 'lib/ruby/rego/cli/profiling.rb', line 130 def self.skip_key?(key) SKIP_KEYS.include?(key) end |
Instance Method Details
#top_objects(limit: 3) ⇒ Object
142 143 144 145 146 147 |
# File 'lib/ruby/rego/cli/profiling.rb', line 142 def top_objects(limit: 3) object_deltas .sort_by { |(_, count)| -count } .first(limit) .map { |(key, count)| "#{key} +#{count}" } end |