Class: RegoValidate::Profiler::Measurement

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

Overview

Tracks measurement state for a single sample.

Instance Method Summary collapse

Constructor Details

#initialize(label:, before:, start:) ⇒ Measurement

Returns a new instance of Measurement.



650
651
652
653
654
# File 'lib/ruby/rego/cli.rb', line 650

def initialize(label:, before:, start:)
  @label = label
  @before = before
  @start = start
end

Instance Method Details

#finish(after:, finish:) ⇒ Object



656
657
658
659
660
661
662
663
664
665
# File 'lib/ruby/rego/cli.rb', line 656

def finish(after:, finish:)
  delta = before.delta(after)
  Sample.new(
    label: label,
    duration_ms: ((finish - start) * 1000.0),
    allocations: delta.allocations,
    memory_bytes: delta.memory_bytes,
    top_objects: delta.top_objects
  )
end