Sha256: 9e3c72de97ff931d19e9d3f73c98cbe078fa259eae9bddb222964a185d7766b3
Contents?: true
Size: 769 Bytes
Versions: 2
Compression:
Stored size: 769 Bytes
Contents
module Whysoslow class MemoryProfile class Snapshot; end attr_reader :snapshots, :divider attr_accessor :units def initialize(units='MB') @snapshots = [] self.units = units end def units=(value) @units, @divider = if value == 'KB' ['KB', 1] else # MB ['MB', 1000] end end def snapshot(label) Snapshot.new(label, @divider).tap { |snap| @snapshots.push(snap) } end end class MemoryProfile::Snapshot attr_reader :label, :memory def initialize(label, divider) @label = label @memory = capture_memory_usage(divider) end protected def capture_memory_usage(divider) ((`ps -o rss= -p #{$$}`.to_i) / divider.to_f) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
whysoslow-0.0.2 | lib/whysoslow/memory_profile.rb |
whysoslow-0.0.1 | lib/whysoslow/memory_profile.rb |