Merge "[Reports] Fix parallel iteration calc in LoadChart"

This commit is contained in:
Jenkins 2016-04-12 10:10:57 +00:00 committed by Gerrit Code Review
commit 7e620b9b3a
2 changed files with 41 additions and 111 deletions

View File

@ -160,10 +160,10 @@ class LoadProfileChart(Chart):
self._duration = workload_info["load_duration"] * (1 + 2.0 / scale)
self._tstamp_start = workload_info["tstamp_start"]
step = self._duration / float(scale)
self._time_axis = [step * x
self.step = self._duration / float(scale)
self._time_axis = [self.step * x
for x in six.moves.range(int(scale))
if (step * x) < self._duration]
if (self.step * x) < self._duration]
self._time_axis.append(self._duration)
self._running = [0] * len(self._time_axis)
@ -175,11 +175,18 @@ class LoadProfileChart(Chart):
ts_start = timestamp - self._tstamp_start
started_idx = bisect.bisect(self._time_axis, ts_start)
ended_idx = bisect.bisect(self._time_axis, ts_start + duration)
if self._time_axis[ended_idx - 1] == ts_start + duration:
ended_idx -= 1
for idx in range(started_idx + 1, ended_idx):
self._running[idx] += 1
self._running[started_idx] += 0.5
self._running[ended_idx] += 0.5
if started_idx == ended_idx:
self._running[ended_idx] += duration / self.step
else:
self._running[started_idx] += (
self._time_axis[started_idx] - ts_start) / self.step
self._running[ended_idx] += (
ts_start + duration
- self._time_axis[ended_idx - 1]) / self.step
def render(self):
return [(self._name, list(zip(self._time_axis, self._running)))]

View File

@ -170,114 +170,37 @@ class AtomicAvgChartTestCase(test.TestCase):
@ddt.ddt
class LoadProfileChartTestCase(test.TestCase):
workload_info = {"iterations_count": 20,
"tstamp_start": 1459421691.607279,
"load_duration": 2.5298428535461426}
iterations = [(1459421691.607279, 0.5002949237823486),
(1459421691.60854, 0.5005340576171875),
(1459421691.612978, 0.5005340576171875),
(1459421691.615876, 0.500960111618042),
(1459421692.110288, 0.5002930164337158),
(1459421692.111956, 0.5004231929779053),
(1459421692.118393, 0.5004739761352539),
(1459421692.125796, 0.5002138614654541),
(1459421692.612263, 0.5001211166381836),
(1459421692.614128, 0.5009160041809082),
(1459421692.620582, 0.5005178451538086),
(1459421692.629205, 0.5005218982696533),
(1459421693.113873, 0.5005190372467041),
(1459421693.117251, 0.5005340576171875),
(1459421693.122341, 0.5060141086578369),
(1459421693.131172, 0.5005171298980713),
(1459421693.616505, 0.5005180835723877),
(1459421693.624986, 0.500521183013916),
(1459421693.629693, 0.5004010200500488),
(1459421693.636602, 0.5005199909210205)]
@ddt.data(
{"info": workload_info,
"iterations": iterations,
"kwargs": {},
"expected": [("parallel iterations",
[(0.0, 0), (0.025804397106170652, 2.0),
(0.051608794212341304, 4), (0.07741319131851196, 4),
(0.10321758842468261, 4), (0.12902198553085326, 4),
(0.15482638263702392, 4), (0.18063077974319455, 4),
(0.20643517684936522, 4), (0.23223957395553588, 4),
(0.2580439710617065, 4), (0.2838483681678772, 4),
(0.30965276527404784, 4), (0.3354571623802185, 4),
(0.3612615594863891, 4), (0.38706595659255977, 4),
(0.41287035369873043, 4), (0.4386747508049011, 4),
(0.46447914791107175, 4), (0.49028354501724236, 4),
(0.516087942123413, 3.5), (0.5418923392295837, 3.5),
(0.5676967363357543, 4), (0.593501133441925, 4),
(0.6193055305480957, 4), (0.6451099276542663, 4),
(0.670914324760437, 4), (0.6967187218666075, 4),
(0.7225231189727782, 4), (0.7483275160789489, 4),
(0.7741319131851195, 4), (0.7999363102912902, 4),
(0.8257407073974609, 4), (0.8515451045036315, 4),
(0.8773495016098022, 4), (0.9031538987159728, 4),
(0.9289582958221435, 4), (0.9547626929283142, 4),
(0.9805670900344847, 4), (1.0063714871406555, 3.5),
(1.032175884246826, 3.5), (1.0579802813529968, 4),
(1.0837846784591674, 4), (1.109589075565338, 4),
(1.1353934726715087, 4), (1.1611978697776792, 4),
(1.18700226688385, 4), (1.2128066639900206, 4),
(1.2386110610961913, 4), (1.264415458202362, 4),
(1.2902198553085327, 4), (1.3160242524147032, 4),
(1.341828649520874, 4), (1.3676330466270445, 4),
(1.393437443733215, 4), (1.4192418408393859, 4),
(1.4450462379455564, 4), (1.4708506350517272, 4),
(1.4966550321578977, 4), (1.5224594292640685, 3.5),
(1.548263826370239, 3.5), (1.5740682234764098, 4),
(1.5998726205825804, 4), (1.6256770176887512, 4),
(1.6514814147949217, 4), (1.6772858119010923, 4),
(1.703090209007263, 4), (1.7288946061134336, 4),
(1.7546990032196044, 4), (1.780503400325775, 4),
(1.8063077974319457, 4), (1.8321121945381162, 4),
(1.857916591644287, 4), (1.8837209887504576, 4),
(1.9095253858566283, 4), (1.935329782962799, 4),
(1.9611341800689694, 4), (1.9869385771751402, 4),
(2.012742974281311, 3.5), (2.0385473713874815, 3.5),
(2.064351768493652, 4), (2.0901561655998226, 4),
(2.1159605627059936, 4), (2.141764959812164, 4),
(2.1675693569183347, 4), (2.1933737540245053, 4),
(2.219178151130676, 4), (2.244982548236847, 4),
(2.2707869453430174, 4), (2.296591342449188, 4),
(2.3223957395553585, 4), (2.3482001366615295, 4),
(2.3740045337677, 4), (2.3998089308738706, 4),
(2.425613327980041, 4), (2.451417725086212, 4),
(2.4772221221923827, 4), (2.5030265192985532, 4),
(2.528830916404724, 2.5), (2.5546353135108943, 0.5),
(2.5804397106170653, 0)])]},
{"info": workload_info,
"iterations": iterations,
"kwargs": {"name": "Custom name", "scale": 8},
"expected": [("Custom name",
[(0.0, 0),
(0.3952879458665848, 2.0),
(0.7905758917331696, 4.0),
(1.1858638375997543, 4.0),
(1.5811517834663391, 4.0),
(1.976439729332924, 4),
(2.3717276751995087, 4.0),
(2.7670156210660934, 2.0),
(3.1623035669326782, 0)])]},
{"info": {"iterations_count": 2,
"tstamp_start": 1459421691.607279,
"load_duration": 2.5298428535461426},
"iterations": [],
{"info": {"iterations_count": 9,
"tstamp_start": 0.0,
"load_duration": 8.0},
"iterations": [(0.0, 0.5), (0.5, 0.5), (2.0, 4.0), (2.0, 2.0),
(4.0, 2.0), (6.0, 0.5), (6.5, 0.5), (7.5, 0.5),
(7.5, 1.5)],
"kwargs": {"scale": 8},
"expected": [("parallel iterations",
[(0.0, 0),
(0.3952879458665848, 0),
(0.7905758917331696, 0),
(1.1858638375997543, 0),
(1.5811517834663391, 0),
(1.976439729332924, 0),
(2.3717276751995087, 0),
(2.7670156210660934, 0),
(3.1623035669326782, 0)])]})
[(0.0, 0), (1.25, 0.8), (2.5, 0.8), (3.75, 2),
(5.0, 2.0), (6.25, 1.8), (7.5, 0.6000000000000001),
(8.75, 1.4), (10.0, 0.2)])]},
{"info": {"iterations_count": 6,
"tstamp_start": 0.0,
"load_duration": 12.0},
"iterations": [(0.0, 0.75), (0.75, 0.75), (1.5, 0.375), (3.0, 5.0),
(3.75, 4.25), (10.0, 1.0)],
"kwargs": {"name": "Custom name", "scale": 8},
"expected": [("Custom name",
[(0.0, 0), (1.875, 1.0), (3.75, 0.4),
(5.625, 2.0), (7.5, 2), (9.375, 0.5333333333333333),
(11.25, 0.5333333333333333), (13.125, 0),
(15.0, 0)])]},
{"info": {"iterations_count": 2,
"tstamp_start": 0.0,
"load_duration": 1.0},
"iterations": [(0.0, 0.5), (0.5, 0.5)],
"kwargs": {"scale": 4},
"expected": [("parallel iterations",
[(0.0, 0), (0.375, 1.0), (0.75, 1.0),
(1.125, 0.6666666666666666), (1.5, 0)])]})
@ddt.unpack
def test_add_iteration_and_render(self, info, iterations, kwargs,
expected):