Class: TuneMyGc::Snapshotter
- Inherits:
-
Object
- Object
- TuneMyGc::Snapshotter
- Defined in:
- lib/tunemygc/snapshotter.rb
Constant Summary collapse
- UNITS_OF_WORK =
/PROCESSING_STARTED|PROCESSING_ENDED/
- TERMINATED =
/TERMINATED/
- MAX_SAMPLES =
(ENV['RUBY_GC_MAX_SAMPLES'] ? Integer(ENV['RUBY_GC_MAX_SAMPLES']) : 2000)
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#stat_keys ⇒ Object
readonly
Returns the value of attribute stat_keys.
-
#unit_of_work ⇒ Object
Returns the value of attribute unit_of_work.
Instance Method Summary collapse
- #clear ⇒ Object
- #deq ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(buf = Queue.new) ⇒ Snapshotter
constructor
A new instance of Snapshotter.
- #size ⇒ Object
- #take(stage, meta = nil) ⇒ Object
-
#take_raw(snapshot) ⇒ Object
low level interface, for tests and GC callback.
Constructor Details
#initialize(buf = Queue.new) ⇒ Snapshotter
Returns a new instance of Snapshotter.
15 16 17 18 19 |
# File 'lib/tunemygc/snapshotter.rb', line 15 def initialize(buf = Queue.new) @buffer = buf @unit_of_work = false @stat_keys = GC.stat.keys end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
11 12 13 |
# File 'lib/tunemygc/snapshotter.rb', line 11 def buffer @buffer end |
#stat_keys ⇒ Object (readonly)
Returns the value of attribute stat_keys.
13 14 15 |
# File 'lib/tunemygc/snapshotter.rb', line 13 def stat_keys @stat_keys end |
#unit_of_work ⇒ Object
Returns the value of attribute unit_of_work.
12 13 14 |
# File 'lib/tunemygc/snapshotter.rb', line 12 def unit_of_work @unit_of_work end |
Instance Method Details
#clear ⇒ Object
30 31 32 |
# File 'lib/tunemygc/snapshotter.rb', line 30 def clear @buffer.clear end |
#deq ⇒ Object
38 39 40 |
# File 'lib/tunemygc/snapshotter.rb', line 38 def deq @buffer.deq end |
#empty? ⇒ Boolean
42 43 44 |
# File 'lib/tunemygc/snapshotter.rb', line 42 def empty? @buffer.empty? end |
#size ⇒ Object
34 35 36 |
# File 'lib/tunemygc/snapshotter.rb', line 34 def size @buffer.size end |
#take(stage, meta = nil) ⇒ Object
21 22 23 |
# File 'lib/tunemygc/snapshotter.rb', line 21 def take(stage, = nil) _buffer([TuneMyGc.walltime, TuneMyGc.peak_rss, TuneMyGc.current_rss, stage, GC.stat.values_at(*stat_keys), GC.latest_gc_info, , thread_id]) end |
#take_raw(snapshot) ⇒ Object
low level interface, for tests and GC callback
26 27 28 |
# File 'lib/tunemygc/snapshotter.rb', line 26 def take_raw(snapshot) _buffer(snapshot) end |