class TimeBandits::TimeConsumers::JMX
Public Class Methods
instance()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 22 def self.instance @instance ||= new end
new()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 14 def initialize @server = ::JMX::MBeanServer.new @memory_bean = @server["java.lang:type=Memory"] @collectors = @server.query_names "java.lang:type=GarbageCollector,*" reset end
Public Instance Methods
allocated_objects()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 69 def allocated_objects 0 end
collections_delta()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 53 def collections_delta gc_collections - @collections end
consumed()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 26 def consumed 0.0 end
gc_collections()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 34 def gc_collections @collectors.to_array.map {|gc| @server[gc].collection_count}.sum end
gc_time()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 30 def gc_time @collectors.to_array.map {|gc| @server[gc].collection_time}.sum end
gc_time_delta()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 57 def gc_time_delta (gc_time - @consumed).to_f end
heap_growth()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 61 def heap_growth heap_size - @heap_committed end
heap_size()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 38 def heap_size @memory_bean.heap_memory_usage.committed end
heap_usage()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 42 def heap_usage @memory_bean.heap_memory_usage.used end
reset()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 46 def reset @consumed = gc_time @collections = gc_collections @heap_committed = heap_size @heap_used = heap_usage end
runtime()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 73 def runtime "GC: %.3f(%d), HP: %d(%d,%d,%d)" % [gc_time_delta, collections_delta, heap_growth, heap_size, allocated_objects, usage_growth] end
usage_growth()
click to toggle source
# File lib/time_bandits/time_consumers/jmx.rb, line 65 def usage_growth heap_usage - @heap_used end