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

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

Issue 241273002: Change "percentage change" function and add comments/test for it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« 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 math
5 import unittest 6 import unittest
6 7
7 # Special import necessary because filename contains dash characters. 8 # Special import necessary because filename contains dash characters.
8 bisect_perf_module = __import__('bisect-perf-regression') 9 bisect_perf_module = __import__('bisect-perf-regression')
9 10
10 11
11 class BisectPerfRegressionTest(unittest.TestCase): 12 class BisectPerfRegressionTest(unittest.TestCase):
12 """Test case for top-level functions in the bisect-perf-regrssion module.""" 13 """Test case for top-level functions in the bisect-perf-regrssion module."""
13 14
14 def setUp(self): 15 def setUp(self):
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 0, bisect_perf_module.CalculateConfidence(bad_values, good_values)) 69 0, bisect_perf_module.CalculateConfidence(bad_values, good_values))
69 70
70 def testCalculateConfidence100(self): 71 def testCalculateConfidence100(self):
71 """Tests the confidence calculation when it's expected to be 100.""" 72 """Tests the confidence calculation when it's expected to be 100."""
72 bad_values = [[1, 1], [1, 1]] 73 bad_values = [[1, 1], [1, 1]]
73 good_values = [[1.2, 1.2], [1.2, 1.2]] 74 good_values = [[1.2, 1.2], [1.2, 1.2]]
74 # Standard deviation in both groups is zero, so confidence is 100. 75 # Standard deviation in both groups is zero, so confidence is 100.
75 self.assertEqual( 76 self.assertEqual(
76 100, bisect_perf_module.CalculateConfidence(bad_values, good_values)) 77 100, bisect_perf_module.CalculateConfidence(bad_values, good_values))
77 78
79 def testCalculateRelativeChange(self):
80 """Tests the common cases for calculating relative change."""
81 # The change is relative to the first value, regardless of which is bigger.
82 self.assertEqual(0.5, bisect_perf_module.CalculateRelativeChange(1.0, 1.5))
83 self.assertEqual(0.5, bisect_perf_module.CalculateRelativeChange(2.0, 1.0))
84
85 def testCalculateRelativeChangeFromZero(self):
86 """Tests what happens when relative change from zero is calculated."""
87 # If the first number is zero, then the result is not a number.
88 self.assertEqual(0, bisect_perf_module.CalculateRelativeChange(0, 0))
89 self.assertTrue(
90 math.isnan(bisect_perf_module.CalculateRelativeChange(0, 1)))
91 self.assertTrue(
92 math.isnan(bisect_perf_module.CalculateRelativeChange(0, -1)))
93
94 def testCalculateRelativeChangeWithNegatives(self):
95 """Tests that relative change given is always positive."""
96 self.assertEqual(3.0, bisect_perf_module.CalculateRelativeChange(-1, 2))
97 self.assertEqual(3.0, bisect_perf_module.CalculateRelativeChange(1, -2))
98 self.assertEqual(1.0, bisect_perf_module.CalculateRelativeChange(-1, -2))
99
100
78 if __name__ == '__main__': 101 if __name__ == '__main__':
79 unittest.main() 102 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