Class: Roby::DRoby::Timepoints::Analysis
- Defined in:
- lib/roby/droby/timepoints.rb
Instance Attribute Summary collapse
-
#current_groups ⇒ Object
readonly
Returns the value of attribute current_groups.
-
#roots ⇒ Object
readonly
Returns the value of attribute roots.
-
#thread_names ⇒ Object
readonly
Returns the value of attribute thread_names.
Instance Method Summary collapse
- #add(time, thread_id, thread_name, name) ⇒ Object
- #flamegraph ⇒ Object
- #format(indent: 0, base_time: roots.each_value.map(&:start_time).min, absolute_times: true) ⇒ Object
- #group_end(time, thread_id, thread_name, name) ⇒ Object
- #group_start(time, thread_id, thread_name, name) ⇒ Object
-
#initialize ⇒ Analysis
constructor
A new instance of Analysis.
Constructor Details
#initialize ⇒ Analysis
Returns a new instance of Analysis.
11 12 13 14 15 16 17 |
# File 'lib/roby/droby/timepoints.rb', line 11 def initialize @thread_names = {} @roots = roots = {} @current_groups = Hash.new do |h, thread_id| roots[thread_id] = h[thread_id] = Root.new(thread_id) end end |
Instance Attribute Details
#current_groups ⇒ Object (readonly)
Returns the value of attribute current_groups.
9 10 11 |
# File 'lib/roby/droby/timepoints.rb', line 9 def current_groups @current_groups end |
#roots ⇒ Object (readonly)
Returns the value of attribute roots.
9 10 11 |
# File 'lib/roby/droby/timepoints.rb', line 9 def roots @roots end |
#thread_names ⇒ Object (readonly)
Returns the value of attribute thread_names.
9 10 11 |
# File 'lib/roby/droby/timepoints.rb', line 9 def thread_names @thread_names end |
Instance Method Details
#add(time, thread_id, thread_name, name) ⇒ Object
19 20 21 22 |
# File 'lib/roby/droby/timepoints.rb', line 19 def add(time, thread_id, thread_name, name) thread_names[thread_id] ||= thread_name current_groups[thread_id].add(time, name) end |
#flamegraph ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/roby/droby/timepoints.rb', line 42 def flamegraph raw = roots.each_value.map(&:flamegraph) folded = Hash.new(0) raw.each_slice(2) do |path, value| folded[path] += value end folded.to_a.sort end |
#format(indent: 0, base_time: roots.each_value.map(&:start_time).min, absolute_times: true) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/roby/droby/timepoints.rb', line 51 def format(indent: 0, base_time: roots.each_value.map(&:start_time).min, absolute_times: true) roots.each_value.map do |root| root.format(indent: indent, base_time: base_time, absolute_times: absolute_times) .join("\n") end.join("\n") end |
#group_end(time, thread_id, thread_name, name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/roby/droby/timepoints.rb', line 29 def group_end(time, thread_id, thread_name, name) thread_names[thread_id] ||= thread_name current_g = current_groups[thread_id] if current_g == roots[thread_id] raise ArgumentError, "called #group_end on the root group" elsif name != current_g.name raise ArgumentError, "mismatching name in #group_end" end current_g = @current_groups[thread_id] = current_g.group current_g.group_end(time) end |
#group_start(time, thread_id, thread_name, name) ⇒ Object
24 25 26 27 |
# File 'lib/roby/droby/timepoints.rb', line 24 def group_start(time, thread_id, thread_name, name) thread_names[thread_id] ||= thread_name @current_groups[thread_id] = current_groups[thread_id].group_start(time, name) end |