Class: RegoValidate::Profiler::Delta

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/cli.rb

Overview

Computes deltas between snapshots.

Constant Summary collapse

SKIP_KEYS =
%i[TOTAL FREE].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allocations:, memory_bytes:, object_deltas:) ⇒ Delta

Returns a new instance of Delta.



632
633
634
635
636
# File 'lib/ruby/rego/cli.rb', line 632

def initialize(allocations:, memory_bytes:, object_deltas:)
  @allocations = allocations
  @memory_bytes = memory_bytes
  @object_deltas = object_deltas
end

Instance Attribute Details

#allocationsObject (readonly)

Returns the value of attribute allocations.



638
639
640
# File 'lib/ruby/rego/cli.rb', line 638

def allocations
  @allocations
end

#memory_bytesObject (readonly)

Returns the value of attribute memory_bytes.



638
639
640
# File 'lib/ruby/rego/cli.rb', line 638

def memory_bytes
  @memory_bytes
end

#object_deltasObject (readonly)

Returns the value of attribute object_deltas.



638
639
640
# File 'lib/ruby/rego/cli.rb', line 638

def object_deltas
  @object_deltas
end

Class Method Details

.skip_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


628
629
630
# File 'lib/ruby/rego/cli.rb', line 628

def self.skip_key?(key)
  SKIP_KEYS.include?(key)
end

Instance Method Details

#top_objects(limit: 3) ⇒ Object



640
641
642
643
644
645
# File 'lib/ruby/rego/cli.rb', line 640

def top_objects(limit: 3)
  object_deltas
    .sort_by { |(_, count)| -count }
    .first(limit)
    .map { |(key, count)| "#{key} +#{count}" }
end