<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15049] CalendarServer/branches/users/sredmond/clientsim/contrib/performance</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15049">15049</a></dd>
<dt>Author</dt> <dd>sredmond@apple.com</dd>
<dt>Date</dt> <dd>2015-08-17 14:15:14 -0700 (Mon, 17 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Separates stats functionality from distributions</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssredmondclientsimcontribperformancestatspy">CalendarServer/branches/users/sredmond/clientsim/contrib/performance/stats.py</a></li>
<li><a href="#CalendarServerbranchesuserssredmondclientsimcontribperformancetest_statspy">CalendarServer/branches/users/sredmond/clientsim/contrib/performance/test_stats.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssredmondclientsimcontribperformancestatspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sredmond/clientsim/contrib/performance/stats.py (15048 => 15049)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sredmond/clientsim/contrib/performance/stats.py        2015-08-17 21:14:42 UTC (rev 15048)
+++ CalendarServer/branches/users/sredmond/clientsim/contrib/performance/stats.py        2015-08-17 21:15:14 UTC (rev 15049)
</span><span class="lines">@@ -15,10 +15,9 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><del>-Implementation of a statistics library for Calendar performance analysis.
</del><ins>+Implementation of a statistics library for performance analysis.
</ins><span class="cx"> Exports:
</span><del>-
-_Statistic object
</del><ins>+_Statistic
</ins><span class="cx">   Duration
</span><span class="cx">   SQLDuration
</span><span class="cx">   Bytes
</span></span></pre></div>
<a id="CalendarServerbranchesuserssredmondclientsimcontribperformancetest_statspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sredmond/clientsim/contrib/performance/test_stats.py (15048 => 15049)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sredmond/clientsim/contrib/performance/test_stats.py        2015-08-17 21:14:42 UTC (rev 15048)
+++ CalendarServer/branches/users/sredmond/clientsim/contrib/performance/test_stats.py        2015-08-17 21:15:14 UTC (rev 15049)
</span><span class="lines">@@ -16,12 +16,7 @@
</span><span class="cx"> 
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><span class="cx"> 
</span><del>-from stats import (
-    SQLDuration, LogNormalDistribution, UniformDiscreteDistribution,
-    UniformIntegerDistribution, WorkDistribution, quantize,
-    RecurrenceDistribution)
-from pycalendar.datetime import DateTime
-from pycalendar.timezone import Timezone
</del><ins>+from stats import SQLDuration
</ins><span class="cx"> 
</span><span class="cx"> class SQLDurationTests(TestCase):
</span><span class="cx">     def setUp(self):
</span><span class="lines">@@ -44,139 +39,3 @@
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             self.stat.normalize('SELECT foo FROM bar WHERE True'),
</span><span class="cx">             'SELECT foo FROM bar WHERE ?')
</span><del>-
-
-
-class DistributionTests(TestCase):
-    def test_lognormal(self):
-        dist = LogNormalDistribution(mu=1, sigma=1)
-        for _ignore_i in range(100):
-            value = dist.sample()
-            self.assertIsInstance(value, float)
-            self.assertTrue(value &gt;= 0.0, &quot;negative value %r&quot; % (value,))
-            self.assertTrue(value &lt;= 1000, &quot;implausibly high value %r&quot; % (value,))
-
-        dist = LogNormalDistribution(mode=1, median=2)
-        for _ignore_i in range(100):
-            value = dist.sample()
-            self.assertIsInstance(value, float)
-            self.assertTrue(value &gt;= 0.0, &quot;negative value %r&quot; % (value,))
-            self.assertTrue(value &lt;= 1000, &quot;implausibly high value %r&quot; % (value,))
-
-        dist = LogNormalDistribution(mode=1, mean=2)
-        for _ignore_i in range(100):
-            value = dist.sample()
-            self.assertIsInstance(value, float)
-            self.assertTrue(value &gt;= 0.0, &quot;negative value %r&quot; % (value,))
-            self.assertTrue(value &lt;= 1000, &quot;implausibly high value %r&quot; % (value,))
-
-        self.assertRaises(ValueError, LogNormalDistribution, mu=1)
-        self.assertRaises(ValueError, LogNormalDistribution, sigma=1)
-        self.assertRaises(ValueError, LogNormalDistribution, mode=1)
-        self.assertRaises(ValueError, LogNormalDistribution, mean=1)
-        self.assertRaises(ValueError, LogNormalDistribution, median=1)
-
-
-    def test_uniformdiscrete(self):
-        population = [1, 5, 6, 9]
-        counts = dict.fromkeys(population, 0)
-        dist = UniformDiscreteDistribution(population)
-        for _ignore_i in range(len(population) * 10):
-            counts[dist.sample()] += 1
-        self.assertEqual(dict.fromkeys(population, 10), counts)
-
-
-    def test_workdistribution(self):
-        tzname = &quot;US/Eastern&quot;
-        dist = WorkDistribution([&quot;mon&quot;, &quot;wed&quot;, &quot;thu&quot;, &quot;sat&quot;], 10, 20, tzname)
-        dist._helperDistribution = UniformDiscreteDistribution([35 * 60 * 60 + 30 * 60])
-        dist.now = lambda tzname = None: DateTime(2011, 5, 29, 18, 5, 36, tzid=tzname)
-        value = dist.sample()
-        self.assertEqual(
-            # Move past three workdays - monday, wednesday, thursday - using 30
-            # of the hours, and then five and a half hours into the fourth
-            # workday, saturday.  Workday starts at 10am, so the sample value
-            # is 3:30pm, ie 1530 hours.
-            DateTime(2011, 6, 4, 15, 30, 0, tzid=Timezone(tzid=tzname)),
-            value
-        )
-
-        dist = WorkDistribution([&quot;mon&quot;, &quot;tue&quot;, &quot;wed&quot;, &quot;thu&quot;, &quot;fri&quot;], 10, 20, tzname)
-        dist._helperDistribution = UniformDiscreteDistribution([35 * 60 * 60 + 30 * 60])
-        value = dist.sample()
-        self.assertTrue(isinstance(value, DateTime))
-
-    # twisted.trial.unittest.FailTest: not equal:
-    # a = datetime.datetime(2011, 6, 4, 15, 30, tzinfo=&lt;DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD&gt;)
-    # b = datetime.datetime(2011, 6, 4, 19, 30, tzinfo=&lt;DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST&gt;)
-    # test_workdistribution.todo = &quot;Somehow timezones mess this up&quot;
-
-
-    def test_recurrencedistribution(self):
-        dist = RecurrenceDistribution(False)
-        for _ignore in range(100):
-            value = dist.sample()
-            self.assertTrue(value is None)
-
-        dist = RecurrenceDistribution(True, {&quot;daily&quot;: 1, &quot;none&quot;: 2, &quot;weekly&quot;: 1})
-        dist._helperDistribution = UniformDiscreteDistribution([0, 3, 2, 1, 0], randomize=False)
-        value = dist.sample()
-        self.assertTrue(value is not None)
-        value = dist.sample()
-        self.assertTrue(value is None)
-        value = dist.sample()
-        self.assertTrue(value is None)
-        value = dist.sample()
-        self.assertTrue(value is not None)
-        value = dist.sample()
-        self.assertTrue(value is not None)
-
-
-    def test_uniform(self):
-        dist = UniformIntegerDistribution(-5, 10)
-        for _ignore_i in range(100):
-            value = dist.sample()
-            self.assertTrue(-5 &lt;= value &lt; 10)
-            self.assertIsInstance(value, int)
-
-
-
-class QuantizationTests(TestCase):
-    &quot;&quot;&quot;
-    Tests for L{quantize} which constructs discrete datasets of
-    dynamic quantization from continuous datasets.
-    &quot;&quot;&quot;
-    skip = &quot;nothing implemented yet, maybe not necessary&quot;
-
-    def test_one(self):
-        &quot;&quot;&quot;
-        A single data point is put into a bucket equal to its value and returned.
-        &quot;&quot;&quot;
-        dataset = [5.0]
-        expected = [(5.0, [5.0])]
-        self.assertEqual(quantize(dataset), expected)
-
-
-    def test_two(self):
-        &quot;&quot;&quot;
-        Each of two values are put into buckets the size of the
-        standard deviation of the sample.
-        &quot;&quot;&quot;
-        dataset = [2.0, 5.0]
-        expected = [(1.5, [2.0]), (4.5, [5.0])]
-        self.assertEqual(quantize(dataset), expected)
-
-
-    def xtest_three(self):
-        &quot;&quot;&quot;
-        If two out of three values fall within one bucket defined by
-        the standard deviation of the sample, that bucket is split in
-        half so each bucket has one value.
-        &quot;&quot;&quot;
-        pass
-
-
-    def xtest_alpha(self):
-        &quot;&quot;&quot;
-        This exercises one simple case of L{quantize} with a small amount of data.
-        &quot;&quot;&quot;
</del></span></pre>
</div>
</div>

</body>
</html>