Class: Benchmark::Memory::MetricExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark/memory/measurement/metric_extractor.rb

Overview

Extracts metrics from a memory profiler result

Class Method Summary collapse

Class Method Details

.extract_memory(result) ⇒ Benchmark::Memory::Measurement::Metric

Extracts the memory-specific metrics from a profiler result

Parameters:

  • result (MemoryProfiler::Results)

Returns:



13
14
15
16
17
18
19
# File 'lib/benchmark/memory/measurement/metric_extractor.rb', line 13

def self.extract_memory(result)
  Measurement::Metric.new(
    :memsize,
    result.total_allocated_memsize,
    result.total_retained_memsize
  )
end

.extract_objects(result) ⇒ Benchmark::Memory::Measurement::Metric

Extracts the object-specific metrics from a profiler result

Parameters:

  • result (MemoryProfiler::Results)

Returns:



25
26
27
28
29
30
31
# File 'lib/benchmark/memory/measurement/metric_extractor.rb', line 25

def self.extract_objects(result)
  Measurement::Metric.new(
    :objects,
    result.total_allocated,
    result.total_retained
  )
end

.extract_strings(result) ⇒ Benchmark::Memory::Measurement::Metric

Extracts the string-specific metrics from a profiler result

Parameters:

  • result (MemoryProfiler::Results)

Returns:



37
38
39
40
41
42
43
# File 'lib/benchmark/memory/measurement/metric_extractor.rb', line 37

def self.extract_strings(result)
  Measurement::Metric.new(
    :strings,
    result.strings_allocated.size,
    result.strings_retained.size
  )
end