Class: TuneMyGc::Interposer
- Inherits:
-
Object
- Object
- TuneMyGc::Interposer
- Defined in:
- lib/tunemygc/interposer.rb
Instance Attribute Summary collapse
-
#installed ⇒ Object
Returns the value of attribute installed.
-
#spy ⇒ Object
readonly
Returns the value of attribute spy.
Instance Method Summary collapse
- #check_uninstall ⇒ Object
-
#initialize(spy = TuneMyGc.spy) ⇒ Interposer
constructor
A new instance of Interposer.
- #install ⇒ Object
- #on_initialized ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(spy = TuneMyGc.spy) ⇒ Interposer
Returns a new instance of Interposer.
10 11 12 13 |
# File 'lib/tunemygc/interposer.rb', line 10 def initialize(spy = TuneMyGc.spy) reset @spy = TuneMyGc::Spies.const_get(spy).new end |
Instance Attribute Details
#installed ⇒ Object
Returns the value of attribute installed.
8 9 10 |
# File 'lib/tunemygc/interposer.rb', line 8 def installed @installed end |
#spy ⇒ Object (readonly)
Returns the value of attribute spy.
7 8 9 |
# File 'lib/tunemygc/interposer.rb', line 7 def spy @spy end |
Instance Method Details
#check_uninstall ⇒ Object
49 50 51 |
# File 'lib/tunemygc/interposer.rb', line 49 def check_uninstall @spy.check_uninstall end |
#install ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tunemygc/interposer.rb', line 23 def install return if @installed TuneMyGc.log "interposing" if TuneMyGc.rails? require 'active_support' ActiveSupport.on_load(:after_initialize) do TuneMyGc.interposer.on_initialized end else TuneMyGc.interposer.on_initialized end TuneMyGc.log "hooked: after_initialize" at_exit do if @installed TuneMyGc.log "at_exit" @spy.uninstall TuneMyGc.snapshot(:TERMINATED) TuneMyGc.reccommendations end end TuneMyGc.log "hooked: at_exit" @installed = true TuneMyGc.log "interposed" end |
#on_initialized ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/tunemygc/interposer.rb', line 15 def on_initialized GC.start(full_mark: true, :immediate_sweep => true) TuneMyGc.install_gc_tracepoint TuneMyGc.log "hooked: GC tracepoints" TuneMyGc.snapshot(:BOOTED) TuneMyGc.interposer.spy.install end |
#uninstall ⇒ Object
53 54 55 56 57 58 |
# File 'lib/tunemygc/interposer.rb', line 53 def uninstall TuneMyGc.uninstall_gc_tracepoint TuneMyGc.log "uninstalled GC tracepoint" @spy.uninstall reset end |