Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure measurements are oreder total-last #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions rebench/model/data_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ def add_measurement(self, measurement):
"'total' measurement.")
self._total = measurement

def _get_measurements_reordered(self):
# re-order so that total is last.
out = [m for m in self._measurements if not m.is_total()]
def _find_total(measurements):
for measurement in measurements:
if measurement.is_total():
return measurement # Highlander
return None
total = _find_total(self._measurements)
if total is not None:
out.append(total)
return out

def get_measurements(self):
if self._measurements and not self._measurements[-1].is_total():
return self._get_measurements_reordered()
return self._measurements

def get_total_value(self):
Expand Down
12 changes: 10 additions & 2 deletions rebench/tests/features/issue_31_multivariate_data_points_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def test_associates_measurements_and_data_points_correctly(self):
for point, i in zip(data_points, list(range(0, 10))):
self.assertEqual(4, point.number_of_measurements())

for criterion, unit, measurement in zip(["bar", "total", "baz", "foo"],
["ms", "ms", "kbyte", "kerf"],
for criterion, unit, measurement in zip(["bar", "baz", "foo", "total"],
["ms", "kbyte", "kerf", "ms"],
point.get_measurements()):
self.assertEqual(criterion, measurement.criterion)
self.assertEqual(i, int(measurement.value))
Expand All @@ -81,3 +81,11 @@ def test_is_compatible_to_issue16_format(self):
point.get_measurements()):
self.assertEqual(criterion, measurement.criterion)
self.assertEqual(i, int(measurement.value))

def test_measurement_ordering(self):
# certain parts of persistency require measurements to be ordered total-last.
# see _DataPointPersistence._process_lines
data_points = self._records_data_points('Test1', 10)
for point in data_points:
measurements = point.get_measurements()
self.assertTrue(measurements[-1].is_total())