Class: Vernier::Hooks::MemoryUsage

Inherits:
Object
  • Object
show all
Defined in:
lib/vernier/hooks/memory_usage.rb

Instance Method Summary collapse

Constructor Details

#initialize(collector) ⇒ MemoryUsage

Returns a new instance of MemoryUsage.



6
7
8
9
# File 'lib/vernier/hooks/memory_usage.rb', line 6

def initialize(collector)
  @collector = collector
  @tracker = Vernier::MemoryTracker.new
end

Instance Method Details

#disableObject



15
16
17
# File 'lib/vernier/hooks/memory_usage.rb', line 15

def disable
  @tracker.stop
end

#enableObject



11
12
13
# File 'lib/vernier/hooks/memory_usage.rb', line 11

def enable
  @tracker.start
end

#firefox_countersObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vernier/hooks/memory_usage.rb', line 19

def firefox_counters
  timestamps, memory = @tracker.results
  memory = ([0] + memory).each_cons(2).map { _2 - _1 }
  {
    name: "memory",
    category: "Memory",
    description: "Memory usage in bytes",
    pid: Process.pid,
    mainThreadIndex: 0,
    samples: {
      time: timestamps.map { _1 / 1_000_000.0 },
      count: memory,
      length: timestamps.length
    }
  }
end