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

Unified Diff: tools/telemetry/telemetry/util/statistics_unittest.py

Issue 185953004: Add some statistics to the monsoon profile run (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to apply upon latest trunk Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/util/statistics.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/util/statistics_unittest.py
diff --git a/tools/perf/metrics/statistics_unittest.py b/tools/telemetry/telemetry/util/statistics_unittest.py
similarity index 88%
rename from tools/perf/metrics/statistics_unittest.py
rename to tools/telemetry/telemetry/util/statistics_unittest.py
index 78fe81ff1511a7d374c93728a6aee1b1f7a790a6..e8b611b2efdb9e9964600136b7191bdcd494b4f9 100644
--- a/tools/perf/metrics/statistics_unittest.py
+++ b/tools/telemetry/telemetry/util/statistics_unittest.py
@@ -4,8 +4,9 @@
import unittest
import random
+import math
-from metrics import statistics
+from telemetry.util import statistics
def Relax(samples, iterations=10):
@@ -158,13 +159,10 @@ class StatisticsUnitTest(unittest.TestCase):
def testArithmeticMean(self):
# The ArithmeticMean function computes the simple average.
- self.assertAlmostEquals(40/3.0, statistics.ArithmeticMean([10, 10, 20], 3))
- self.assertAlmostEquals(15.0, statistics.ArithmeticMean([10, 20], 2))
- # Both lists of values or single values can be given for either argument.
- self.assertAlmostEquals(40/3.0, statistics.ArithmeticMean(40, [1, 1, 1]))
+ self.assertAlmostEquals(40/3.0, statistics.ArithmeticMean([10, 10, 20]))
+ self.assertAlmostEquals(15.0, statistics.ArithmeticMean([10, 20]))
# If the 'count' is zero, then zero is returned.
- self.assertEquals(0, statistics.ArithmeticMean(4.0, 0))
- self.assertEquals(0, statistics.ArithmeticMean(4.0, []))
+ self.assertEquals(0, statistics.ArithmeticMean([]))
def testDurationsDiscrepancy(self):
durations = []
@@ -184,3 +182,18 @@ class StatisticsUnitTest(unittest.TestCase):
d_c = statistics.DurationsDiscrepancy(durations_c)
self.assertTrue(d_a < d_b < d_c)
+
+ def testStandardDeviation(self):
+ self.assertAlmostEquals(math.sqrt(2/3.0),
+ statistics.StandardDeviation([1, 2, 3]))
+ self.assertEquals(0, statistics.StandardDeviation([1]))
+ self.assertEquals(0, statistics.StandardDeviation([]))
+
+ def testTrapezoidalRule(self):
+ self.assertEquals(4, statistics.TrapezoidalRule([1, 2, 3], 1))
+ self.assertEquals(2, statistics.TrapezoidalRule([1, 2, 3], .5))
+ self.assertEquals(0, statistics.TrapezoidalRule([1, 2, 3], 0))
+ self.assertEquals(-4, statistics.TrapezoidalRule([1, 2, 3], -1))
+ self.assertEquals(3, statistics.TrapezoidalRule([-1, 2, 3], 1))
+ self.assertEquals(0, statistics.TrapezoidalRule([1], 1))
+ self.assertEquals(0, statistics.TrapezoidalRule([0], 1))
« no previous file with comments | « tools/telemetry/telemetry/util/statistics.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698