Class: Skylight::VM::GC Private
- Defined in:
- lib/skylight/vm/gc.rb,
lib/skylight/vm/gc.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This doesn’t quite work as we would like it. I believe that the GC statistics includes time that is not stop-the-world, this does not necessarily take time away from the application.
require ‘java’ class GC
def initialize
@factory = Java::JavaLangManagement::ManagementFactory
end
def enable
end
def total_time
res = 0.0
@factory.garbage_collector_mx_beans.each do |mx|
res += (mx.collection_time.to_f / 1_000.0)
end
res
end
end
Instance Method Summary collapse
- #enable ⇒ Object private
-
#initialize ⇒ GC
constructor
private
A new instance of GC.
- #total_time ⇒ Object private
Constructor Details
#initialize ⇒ GC
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GC.
30 31 32 |
# File 'lib/skylight/vm/gc.rb', line 30 def initialize @total = 0 end |
Instance Method Details
#enable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/skylight/vm/gc.rb', line 34 def enable ::GC::Profiler.enable end |
#total_time ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 |
# File 'lib/skylight/vm/gc.rb', line 38 def total_time # Reported in seconds run = (::GC::Profiler.total_time * 1_000_000).to_i ::GC::Profiler.clear if run > 0 @total += run end |