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

Side by Side Diff: tools/telemetry/telemetry/util/statistics_unittest.py

Issue 226613004: telemetry: add additional discrepancy test cases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 import random 6 import random
7 import math 7 import math
8 8
9 from telemetry.util import statistics 9 from telemetry.util import statistics
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 self.assertEquals(d, 1.0) 92 self.assertEquals(d, 1.0)
93 93
94 samples = [0.5, 0.5, 0.5] 94 samples = [0.5, 0.5, 0.5]
95 d = statistics.Discrepancy(samples) 95 d = statistics.Discrepancy(samples)
96 self.assertEquals(d, 1.0) 96 self.assertEquals(d, 1.0)
97 97
98 samples = [1.0/8.0, 3.0/8.0, 5.0/8.0, 7.0/8.0] 98 samples = [1.0/8.0, 3.0/8.0, 5.0/8.0, 7.0/8.0]
99 d = statistics.Discrepancy(samples) 99 d = statistics.Discrepancy(samples)
100 self.assertEquals(d, 0.25) 100 self.assertEquals(d, 0.25)
101 101
102 samples = [1.0/8.0, 5.0/8.0, 5.0/8.0, 7.0/8.0]
103 d = statistics.Discrepancy(samples)
104 self.assertEquals(d, 0.5)
105
106 samples = [1.0/8.0, 3.0/8.0, 5.0/8.0, 5.0/8.0, 7.0/8.0]
107 d = statistics.Discrepancy(samples)
108 self.assertEquals(d, 0.4)
109
102 samples = [0.0, 1.0/3.0, 2.0/3.0, 1.0] 110 samples = [0.0, 1.0/3.0, 2.0/3.0, 1.0]
103 d = statistics.Discrepancy(samples) 111 d = statistics.Discrepancy(samples)
104 self.assertEquals(d, 0.5) 112 self.assertEquals(d, 0.5)
105 113
106 samples = statistics.NormalizeSamples(samples)[0] 114 samples = statistics.NormalizeSamples(samples)[0]
107 d = statistics.Discrepancy(samples) 115 d = statistics.Discrepancy(samples)
108 self.assertEquals(d, 0.25) 116 self.assertEquals(d, 0.25)
109 117
110 def testTimestampsDiscrepancy(self): 118 def testTimestampsDiscrepancy(self):
111 time_stamps = [] 119 time_stamps = []
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 self.assertEquals(0, statistics.StandardDeviation([])) 210 self.assertEquals(0, statistics.StandardDeviation([]))
203 211
204 def testTrapezoidalRule(self): 212 def testTrapezoidalRule(self):
205 self.assertEquals(4, statistics.TrapezoidalRule([1, 2, 3], 1)) 213 self.assertEquals(4, statistics.TrapezoidalRule([1, 2, 3], 1))
206 self.assertEquals(2, statistics.TrapezoidalRule([1, 2, 3], .5)) 214 self.assertEquals(2, statistics.TrapezoidalRule([1, 2, 3], .5))
207 self.assertEquals(0, statistics.TrapezoidalRule([1, 2, 3], 0)) 215 self.assertEquals(0, statistics.TrapezoidalRule([1, 2, 3], 0))
208 self.assertEquals(-4, statistics.TrapezoidalRule([1, 2, 3], -1)) 216 self.assertEquals(-4, statistics.TrapezoidalRule([1, 2, 3], -1))
209 self.assertEquals(3, statistics.TrapezoidalRule([-1, 2, 3], 1)) 217 self.assertEquals(3, statistics.TrapezoidalRule([-1, 2, 3], 1))
210 self.assertEquals(0, statistics.TrapezoidalRule([1], 1)) 218 self.assertEquals(0, statistics.TrapezoidalRule([1], 1))
211 self.assertEquals(0, statistics.TrapezoidalRule([0], 1)) 219 self.assertEquals(0, statistics.TrapezoidalRule([0], 1))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698