Class: Vernier::Hooks::MemoryUsage
- Inherits:
-
Object
- Object
- Vernier::Hooks::MemoryUsage
- Defined in:
- lib/vernier/hooks/memory_usage.rb
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
- #firefox_counters ⇒ Object
-
#initialize(collector) ⇒ MemoryUsage
constructor
A new instance of MemoryUsage.
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
#disable ⇒ Object
15 16 17 |
# File 'lib/vernier/hooks/memory_usage.rb', line 15 def disable @tracker.stop end |
#enable ⇒ Object
11 12 13 |
# File 'lib/vernier/hooks/memory_usage.rb', line 11 def enable @tracker.start end |
#firefox_counters ⇒ Object
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 , 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: .map { _1 / 1_000_000.0 }, count: memory, length: .length } } end |