Class: GCInfo
- Inherits:
-
Object
- Object
- GCInfo
- Defined in:
- lib/railsbench/gc_info.rb
Constant Summary collapse
- OBJECT_TYPES =
%w(NODE STRING ARRAY HASH SCOPE VARMAP CLASS ICLASS REGEXP FLOAT MATCH FILE DATA MODULE OBJECT)
Instance Attribute Summary collapse
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#freed_objects ⇒ Object
readonly
Returns the value of attribute freed_objects.
-
#garbage_produced ⇒ Object
readonly
Returns the value of attribute garbage_produced.
-
#garbage_totals ⇒ Object
readonly
Returns the value of attribute garbage_totals.
-
#leaked ⇒ Object
readonly
Returns the value of attribute leaked.
-
#leaks ⇒ Object
readonly
Returns the value of attribute leaks.
-
#live_objects ⇒ Object
readonly
Returns the value of attribute live_objects.
-
#malloced ⇒ Object
readonly
Returns the value of attribute malloced.
-
#mallocs ⇒ Object
readonly
Returns the value of attribute mallocs.
-
#num_requests ⇒ Object
readonly
Returns the value of attribute num_requests.
-
#object_types ⇒ Object
readonly
Returns the value of attribute object_types.
-
#time_total ⇒ Object
readonly
Returns the value of attribute time_total.
-
#topology ⇒ Object
readonly
Returns the value of attribute topology.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file) ⇒ GCInfo
constructor
A new instance of GCInfo.
Constructor Details
#initialize(file) ⇒ GCInfo
Returns a new instance of GCInfo.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/railsbench/gc_info.rb', line 62 def initialize(file) @entries = [] @num_requests = 0 @topology = [] @object_types = Set.new @mallocs = @malloced = @leaks = @leaked = 0 file.each_line do |line| case line when /^Garbage collection started$/ @entries << GCLogEntry.new when /^objects processed\s*:\s*(\d+)$/ @entries.last.processed = $1.to_i when /^live objects\s*:\s*(\d+)$/ @entries.last.live = $1.to_i when /^freelist objects\s*:\s*(\d+)$/ @entries.last.freelist = $1.to_i when /^freed objects\s*:\s*(\d+)$/ @entries.last.freed = $1.to_i when /^GC time\s*:\s*(\d+)\s*msec$/ @entries.last.time = $1.to_i when /^number of requests processed: (\d+)$/ @num_requests = $1.to_i when /^HEAP\[\s*(\d+)\]: size=\s*(\d+)$/ @topology = [] if $1.to_i == 0 @topology << $2.to_i when /^kept (\d+) \/ freed (\d+) objects of type ([a-zA-Z]+)/ @object_types.add($3) @entries.last.live_objects[$3] = $1.to_i @entries.last.freed_objects[$3] = $2.to_i when /^(\d+) nodes malloced for (\d+) KB$/ @mallocs = $1.to_i @malloced = $2.to_i * 1024 when /^(\d+) leaks for (\d+) total leaked bytes.$/ @leaks = $1.to_i @leaked = $2.to_i end end @time_total = @entries.map{|e| e.time}.sum @collections = @entries.length @garbage_produced = @entries.map{|e| e.freed}.sum @live_objects = @entries.map{|e| e.live_objects} @freed_objects = @entries.map{|e| e.freed_objects} @freelist = @entries.map{|e| e.freelist} @garbage_totals = @freed_objects.inject(Hash.new(0)) do |totals, freed| freed.each do |object_type, count| totals[object_type] += freed[object_type] || 0 end totals end GCAttributes.each do |attr| a = @entries.map{|e| e.send attr} # we need to pop the last entry, as the freelist is not empty when doing the last forced GC a.pop if :freelist == attr.to_sym [:min, :max, :mean].each do |method| instance_variable_set "@#{attr}_#{method}", (a.send method) end mean = instance_variable_get "@#{attr}_mean" stddev = instance_variable_set "@#{attr}_stddev", (a.send :stddev, mean) instance_variable_set "@#{attr}_stddev_percentage", stddev_percentage(stddev, mean) end end |
Instance Attribute Details
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
52 53 54 |
# File 'lib/railsbench/gc_info.rb', line 52 def collections @collections end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
52 53 54 |
# File 'lib/railsbench/gc_info.rb', line 52 def entries @entries end |
#freed_objects ⇒ Object (readonly)
Returns the value of attribute freed_objects.
53 54 55 |
# File 'lib/railsbench/gc_info.rb', line 53 def freed_objects @freed_objects end |
#garbage_produced ⇒ Object (readonly)
Returns the value of attribute garbage_produced.
52 53 54 |
# File 'lib/railsbench/gc_info.rb', line 52 def garbage_produced @garbage_produced end |
#garbage_totals ⇒ Object (readonly)
Returns the value of attribute garbage_totals.
53 54 55 |
# File 'lib/railsbench/gc_info.rb', line 53 def garbage_totals @garbage_totals end |
#leaked ⇒ Object (readonly)
Returns the value of attribute leaked.
54 55 56 |
# File 'lib/railsbench/gc_info.rb', line 54 def leaked @leaked end |
#leaks ⇒ Object (readonly)
Returns the value of attribute leaks.
54 55 56 |
# File 'lib/railsbench/gc_info.rb', line 54 def leaks @leaks end |
#live_objects ⇒ Object (readonly)
Returns the value of attribute live_objects.
53 54 55 |
# File 'lib/railsbench/gc_info.rb', line 53 def live_objects @live_objects end |
#malloced ⇒ Object (readonly)
Returns the value of attribute malloced.
54 55 56 |
# File 'lib/railsbench/gc_info.rb', line 54 def malloced @malloced end |
#mallocs ⇒ Object (readonly)
Returns the value of attribute mallocs.
54 55 56 |
# File 'lib/railsbench/gc_info.rb', line 54 def mallocs @mallocs end |
#num_requests ⇒ Object (readonly)
Returns the value of attribute num_requests.
52 53 54 |
# File 'lib/railsbench/gc_info.rb', line 52 def num_requests @num_requests end |
#object_types ⇒ Object (readonly)
Returns the value of attribute object_types.
53 54 55 |
# File 'lib/railsbench/gc_info.rb', line 53 def object_types @object_types end |
#time_total ⇒ Object (readonly)
Returns the value of attribute time_total.
52 53 54 |
# File 'lib/railsbench/gc_info.rb', line 52 def time_total @time_total end |
#topology ⇒ Object (readonly)
Returns the value of attribute topology.
52 53 54 |
# File 'lib/railsbench/gc_info.rb', line 52 def topology @topology end |
Class Method Details
.object_types(list_of_gc_infos) ⇒ Object
131 132 133 134 135 |
# File 'lib/railsbench/gc_info.rb', line 131 def object_types(list_of_gc_infos) list_of_gc_infos.inject(OBJECT_TYPES) do |object_types, gci| (object_types + gci.object_types.to_a).uniq end end |