Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: tools/bisect-perf-regression_test.py

Issue 463743002: Return 0 for confidence when there's only results for one "good" or one "bad" rev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 from auto_bisect import source_control as source_control_module 7 from auto_bisect import source_control as source_control_module
8 8
9 # Special import necessary because filename contains dash characters. 9 # Special import necessary because filename contains dash characters.
10 bisect_perf_module = __import__('bisect-perf-regression') 10 bisect_perf_module = __import__('bisect-perf-regression')
11 11
12 12
13 class BisectPerfRegressionTest(unittest.TestCase): 13 class BisectPerfRegressionTest(unittest.TestCase):
14 """Test case for other functions and classes in bisect-perf-regression.py.""" 14 """Test case for other functions and classes in bisect-perf-regression.py."""
15 15
16 def _AssertConfidence(self, score, bad_values, good_values): 16 def _AssertConfidence(self, score, bad_values, good_values):
17 """Checks whether the given sets of values have a given confidence score. 17 """Checks whether the given sets of values have a given confidence score.
18 18
19 The score represents our confidence that the two sets of values wouldn't 19 The score represents our confidence that the two sets of values wouldn't
20 be as different as they are just by chance; that is, that some real change 20 be as different as they are just by chance; that is, that some real change
21 occurred between the two sets of values. 21 occurred between the two sets of values.
22 22
23 Args: 23 Args:
24 score: Expected confidence score. 24 score: Expected confidence score.
25 bad_values: First list of numbers. 25 bad_values: First list of numbers.
26 good_values: Second list of numbers. 26 good_values: Second list of numbers.
27 """ 27 """
28 # ConfidenceScore takes a list of lists but these lists are flattened. 28 # ConfidenceScore takes a list of lists but these lists are flattened
29 confidence = bisect_perf_module.ConfidenceScore([bad_values], [good_values]) 29 # inside the function.
30 confidence = bisect_perf_module.ConfidenceScore(
31 [[v] for v in bad_values],
32 [[v] for v in good_values])
30 self.assertEqual(score, confidence) 33 self.assertEqual(score, confidence)
31 34
32 def testConfidenceScore_ZeroConfidence(self): 35 def testConfidenceScore_ZeroConfidence(self):
33 # The good and bad sets contain the same values, so the confidence that 36 # The good and bad sets contain the same values, so the confidence that
34 # they're different should be zero. 37 # they're different should be zero.
35 self._AssertConfidence(0.0, [4, 5, 7, 6, 8, 7], [8, 7, 6, 7, 5, 4]) 38 self._AssertConfidence(0.0, [4, 5, 7, 6, 8, 7], [8, 7, 6, 7, 5, 4])
36 39
37 def testConfidenceScore_MediumConfidence(self): 40 def testConfidenceScore_MediumConfidence(self):
38 self._AssertConfidence(80.0, [0, 1, 1, 1, 2, 2], [1, 1, 1, 3, 3, 4]) 41 self._AssertConfidence(80.0, [0, 1, 1, 1, 2, 2], [1, 1, 1, 3, 3, 4])
39 42
40 def testConfidenceScore_HighConfidence(self): 43 def testConfidenceScore_HighConfidence(self):
41 self._AssertConfidence(95.0, [0, 1, 1, 1, 2, 2], [1, 2, 2, 3, 3, 4]) 44 self._AssertConfidence(95.0, [0, 1, 1, 1, 2, 2], [1, 2, 2, 3, 3, 4])
42 45
43 def testConfidenceScore_VeryHighConfidence(self): 46 def testConfidenceScore_VeryHighConfidence(self):
44 # Confidence is high if the two sets of values have no internal variance. 47 # Confidence is high if the two sets of values have no internal variance.
45 self._AssertConfidence(99.9, [1, 1, 1, 1], [1.2, 1.2, 1.2, 1.2]) 48 self._AssertConfidence(99.9, [1, 1, 1, 1], [1.2, 1.2, 1.2, 1.2])
46 self._AssertConfidence(99.9, [1, 1, 1, 1], [1.01, 1.01, 1.01, 1.01]) 49 self._AssertConfidence(99.9, [1, 1, 1, 1], [1.01, 1.01, 1.01, 1.01])
47 50
48 def testConfidenceScore_ImbalancedSampleSize(self): 51 def testConfidenceScore_UnbalancedSampleSize(self):
49 # The second set of numbers only contains one number, so confidence is low. 52 # The second set of numbers only contains one number, so confidence is 0.
50 self._AssertConfidence( 53 self._AssertConfidence(0.0, [1.1, 1.2, 1.1, 1.2, 1.0, 1.3, 1.2], [1.4])
51 80.0, [1.1, 1.2, 1.1, 1.2, 1.0, 1.3, 1.2, 1.3],[1.4])
52 54
53 def testConfidenceScore_EmptySample(self): 55 def testConfidenceScore_EmptySample(self):
54 # Confidence is zero if either or both samples are empty. 56 # Confidence is zero if either or both samples are empty.
55 self._AssertConfidence(0.0, [], []) 57 self._AssertConfidence(0.0, [], [])
56 self._AssertConfidence(0.0, [], [1.1, 1.2, 1.1, 1.2, 1.0, 1.3, 1.2, 1.3]) 58 self._AssertConfidence(0.0, [], [1.1, 1.2, 1.1, 1.2, 1.0, 1.3, 1.2, 1.3])
57 self._AssertConfidence(0.0, [1.1, 1.2, 1.1, 1.2, 1.0, 1.3, 1.2, 1.3], []) 59 self._AssertConfidence(0.0, [1.1, 1.2, 1.1, 1.2, 1.0, 1.3, 1.2, 1.3], [])
58 60
59 def testConfidenceScore_FunctionalTestResults(self): 61 def testConfidenceScore_FunctionalTestResults(self):
60 self._AssertConfidence(80.0, [1, 1, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 1, 0]) 62 self._AssertConfidence(80.0, [1, 1, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 1, 0])
61 self._AssertConfidence(99.9, [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]) 63 self._AssertConfidence(99.9, [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0])
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 source_control, bisect_options) 223 source_control, bisect_options)
222 results = bisect_instance.Run(bisect_options.command, 224 results = bisect_instance.Run(bisect_options.command,
223 bisect_options.bad_revision, 225 bisect_options.bad_revision,
224 bisect_options.good_revision, 226 bisect_options.good_revision,
225 bisect_options.metric) 227 bisect_options.metric)
226 bisect_instance.FormatAndPrintResults(results) 228 bisect_instance.FormatAndPrintResults(results)
227 229
228 230
229 if __name__ == '__main__': 231 if __name__ == '__main__':
230 unittest.main() 232 unittest.main()
OLDNEW
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698