[LNT] r240423 - Don't crash when aggregation of samples results in 0 value in ComparisonResult constructor.
Kristof Beyls
kristof.beyls at arm.com
Tue Jun 23 08:50:57 PDT 2015
Author: kbeyls
Date: Tue Jun 23 10:50:56 2015
New Revision: 240423
URL: http://llvm.org/viewvc/llvm-project?rev=240423&view=rev
Log:
Don't crash when aggregation of samples results in 0 value in ComparisonResult constructor.
Modified:
lnt/trunk/lnt/server/reporting/analysis.py
lnt/trunk/tests/server/reporting/analysis.py
Modified: lnt/trunk/lnt/server/reporting/analysis.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/reporting/analysis.py?rev=240423&r1=240422&r2=240423&view=diff
==============================================================================
--- lnt/trunk/lnt/server/reporting/analysis.py (original)
+++ lnt/trunk/lnt/server/reporting/analysis.py Tue Jun 23 10:50:56 2015
@@ -68,12 +68,12 @@ class ComparisonResult:
self.previous = None
# Compute the comparison status for the test value.
- if self.current and self.previous and self.previous != 0:
+ self.delta = 0
+ self.pct_delta = 0.0
+ if self.current and self.previous:
self.delta, value = absmin_diff(self.current, prev_samples)
- self.pct_delta = self.delta / value
- else:
- self.delta = 0
- self.pct_delta = 0.0
+ if value != 0:
+ self.pct_delta = self.delta / value
# If we have multiple values for this run, use that to estimate the
# distribution.
Modified: lnt/trunk/tests/server/reporting/analysis.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/reporting/analysis.py?rev=240423&r1=240422&r2=240423&view=diff
==============================================================================
--- lnt/trunk/tests/server/reporting/analysis.py (original)
+++ lnt/trunk/tests/server/reporting/analysis.py Tue Jun 23 10:50:56 2015
@@ -6,6 +6,7 @@ import unittest
from lnt.server.reporting.analysis import ComparisonResult, REGRESSED, IMPROVED
from lnt.server.reporting.analysis import UNCHANGED_PASS, UNCHANGED_FAIL
from lnt.server.reporting.analysis import absmin_diff
+from lnt.util.stats import median
FLAT_LINE = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
@@ -298,6 +299,12 @@ class ComparisonResultTest(unittest.Test
# Fixme
# self.assertEquals(slow.get_value_status(), IMPROVED)
+ def test_handle_zero_sample(self):
+ for agfn in (min, median):
+ zeroSample = ComparisonResult(
+ agfn, False, False, [0.005, 0.0047, 0.0048], [0.0, 0.01, 0.01])
+ self.assertEquals(zeroSample.get_value_status(), UNCHANGED_PASS)
+
class AbsMinTester(unittest.TestCase):
More information about the llvm-commits
mailing list