Class: Roby::DRoby::Timepoints::Aggregate
- Defined in:
- lib/roby/droby/timepoints.rb
Instance Attribute Summary collapse
-
#current_time ⇒ Object
readonly
Returns the value of attribute current_time.
-
#timepoints ⇒ Object
readonly
Returns the value of attribute timepoints.
Instance Method Summary collapse
- #add(time, name) ⇒ Object
- #duration ⇒ Object
- #end_time ⇒ Object
- #flamegraph ⇒ Object
- #format(indent: 0, last_time: start_time, base_time: start_time, absolute_times: true) ⇒ Object
- #group_end(time) ⇒ Object
- #group_start(time, name) ⇒ Object
-
#initialize ⇒ Aggregate
constructor
A new instance of Aggregate.
- #path ⇒ Object
- #start_time ⇒ Object
Constructor Details
#initialize ⇒ Aggregate
Returns a new instance of Aggregate.
89 90 91 |
# File 'lib/roby/droby/timepoints.rb', line 89 def initialize @timepoints = [] end |
Instance Attribute Details
#current_time ⇒ Object (readonly)
Returns the value of attribute current_time.
87 88 89 |
# File 'lib/roby/droby/timepoints.rb', line 87 def current_time @current_time end |
#timepoints ⇒ Object (readonly)
Returns the value of attribute timepoints.
87 88 89 |
# File 'lib/roby/droby/timepoints.rb', line 87 def timepoints @timepoints end |
Instance Method Details
#add(time, name) ⇒ Object
105 106 107 108 |
# File 'lib/roby/droby/timepoints.rb', line 105 def add(time, name) timepoints << Point.new(time, name, time - (current_time || time), self) @current_time = time end |
#duration ⇒ Object
101 102 103 |
# File 'lib/roby/droby/timepoints.rb', line 101 def duration end_time - start_time end |
#end_time ⇒ Object
97 98 99 |
# File 'lib/roby/droby/timepoints.rb', line 97 def end_time timepoints.last.end_time end |
#flamegraph ⇒ Object
147 148 149 150 151 152 153 154 155 |
# File 'lib/roby/droby/timepoints.rb', line 147 def flamegraph result = [] duration = timepoints.inject(0) do |d, tp| result.concat(tp.flamegraph) d + tp.duration end result << path << self.duration - duration result end |
#format(indent: 0, last_time: start_time, base_time: start_time, absolute_times: true) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/roby/droby/timepoints.rb', line 121 def format(indent: 0, last_time: start_time, base_time: start_time, absolute_times: true) start_format = "%5.3f %5.3f #{' ' * indent}%s" end_format = "%5.3f %5.3f %5.3f #{' ' * indent}%s" line_format = "%5.3f %5.3f #{' ' * indent} %s" result = [] result << Kernel.format(start_format, start_time - base_time, start_time - last_time, "#{name}:start") last_time = timepoints.inject(last_time) do |last, tp| if tp.respond_to?(:format) result.concat(tp.format(last_time: last, indent: indent + 2, base_time: base_time, absolute_times: absolute_times)) tp.end_time else result << Kernel.format(line_format, tp.time - base_time, tp.time - last, tp.name) tp.time end end result << Kernel.format(end_format, end_time - base_time, end_time - last_time, duration, "#{name}:end") result end |
#group_end(time) ⇒ Object
116 117 118 119 |
# File 'lib/roby/droby/timepoints.rb', line 116 def group_end(time) timepoints.last.close(time) @current_time = time end |
#group_start(time, name) ⇒ Object
110 111 112 113 114 |
# File 'lib/roby/droby/timepoints.rb', line 110 def group_start(time, name) group = Group.new(time, name, self) timepoints << group group end |
#path ⇒ Object
143 144 145 |
# File 'lib/roby/droby/timepoints.rb', line 143 def path [name] end |
#start_time ⇒ Object
93 94 95 |
# File 'lib/roby/droby/timepoints.rb', line 93 def start_time timepoints.first.start_time end |