
This patch introduces the following changes. 1. We often have multiple executions of the same atomic action in a single rally iteration. Existing rally charts do not show duration for duplicate actions in an iteration accurately. This patch introduces line charts for each occurence of a duplicate atomic action for each instance, by passing it as additive data. 2. This patch also adds a per iteration stacked area chart that shows data per iteration for each occurence of all atomic actions in the iteration. 3. This patch also adds a duration line chart for each resource created by Rally. Co-authored-by: venkata anil <anilvenkata@redhat.com> Change-Id: I44dafad69cdbcd6db7c8fd9148f1b35d89924e03
82 lines
3.2 KiB
Python
82 lines
3.2 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from rally.common.plugin import plugin
|
|
from rally.task.processing import charts
|
|
from rally.task.processing import utils
|
|
|
|
@plugin.configure(name="ResourceDurationLines")
|
|
class ResourceDurationOutputLinesChart(charts.OutputStackedAreaChart):
|
|
"""Display resource duration data as generic chart with lines.
|
|
|
|
This plugin processes additive data and displays it in HTML report
|
|
as linear chart with X axis bound to iteration number.
|
|
Complete output data is displayed as linear chart as well, without
|
|
any processing.
|
|
|
|
Examples of using this plugin in Scenario, for saving output data:
|
|
|
|
.. code-block:: python
|
|
|
|
self.add_output(
|
|
additive={"title": "Resources atomic action duration line chart",
|
|
"description": "Resources trend",
|
|
"chart_plugin": "ResourceDurationLines",
|
|
"data": [["foo", 12], ["bar", 34]],
|
|
"label": "Duration(in seconds)",
|
|
"axis_label": "Resource count"})
|
|
"""
|
|
|
|
widget = "Lines"
|
|
|
|
def add_iteration(self, iteration):
|
|
"""Add iteration data.
|
|
This method must be called for each iteration.
|
|
:param iteration: list, resource duration data for current iteration
|
|
"""
|
|
atomic_count = {}
|
|
self.max_count = 0
|
|
for name, value in iteration:
|
|
if name not in atomic_count.keys():
|
|
atomic_count[name] = 1
|
|
else:
|
|
atomic_count[name] += 1
|
|
self.max_count = max(self.max_count, atomic_count[name])
|
|
|
|
for name, value in iteration:
|
|
if name not in self._data:
|
|
self._data[name] = utils.GraphZipper(self.base_size*self.max_count,
|
|
self.zipped_size)
|
|
self._data[name].add_point(value)
|
|
|
|
def zeropad_duration_data(self):
|
|
"""Some actions might have been executed more times than other actions
|
|
in the same iteration. Zeroes are appended to make the numbers equal.
|
|
"""
|
|
for key in self._data:
|
|
i = len(self._data[key].get_zipped_graph())
|
|
while i < self.base_size*self.max_count:
|
|
i += 1
|
|
self._data[key].add_point(0)
|
|
|
|
def render(self):
|
|
"""Render HTML from resource duration data"""
|
|
self.zeropad_duration_data()
|
|
render_data = [(name, points.get_zipped_graph())
|
|
for name, points in self._data.items()]
|
|
return {"title": self.title,
|
|
"description": self.description,
|
|
"widget": self.widget,
|
|
"data": render_data,
|
|
"label": self.label,
|
|
"axis_label": self.axis_label}
|