[CalendarServer-changes] [6100] CalendarServer/trunk/contrib/performance
source_changes at macosforge.org
source_changes at macosforge.org
Tue Aug 17 17:35:08 PDT 2010
Revision: 6100
http://trac.macosforge.org/projects/calendarserver/changeset/6100
Author: exarkun at twistedmatrix.com
Date: 2010-08-17 17:35:07 -0700 (Tue, 17 Aug 2010)
Log Message:
-----------
simple student's t test, applicable to the urlopen times at least
Added Paths:
-----------
CalendarServer/trunk/contrib/performance/compare
CalendarServer/trunk/contrib/performance/compare.py
Added: CalendarServer/trunk/contrib/performance/compare
===================================================================
--- CalendarServer/trunk/contrib/performance/compare (rev 0)
+++ CalendarServer/trunk/contrib/performance/compare 2010-08-18 00:35:07 UTC (rev 6100)
@@ -0,0 +1,3 @@
+#!/usr/bin/python
+from compare import main
+main()
Property changes on: CalendarServer/trunk/contrib/performance/compare
___________________________________________________________________
Added: svn:executable
+ *
Added: CalendarServer/trunk/contrib/performance/compare.py
===================================================================
--- CalendarServer/trunk/contrib/performance/compare.py (rev 0)
+++ CalendarServer/trunk/contrib/performance/compare.py 2010-08-18 00:35:07 UTC (rev 6100)
@@ -0,0 +1,41 @@
+import sys, pickle
+
+import stats
+
+try:
+ from scipy.stats import ttest_1samp
+except ImportError:
+ from math import pi
+ from ctypes import CDLL, c_double
+ libc = CDLL('libc.dylib')
+ gamma = libc.gamma
+ gamma.argtypes = [c_double]
+ gamma.restype = c_double
+ def ttest_1samp(a, popmean):
+ t = (stats.mean(a) - popmean) / (stats.stddev(a) / len(a) ** 0.5)
+ v = len(a) - 1.0
+ p = gamma((v + 1) / 2) / ((v * pi) ** 0.5 * gamma(v / 2)) * (1 + t ** 2 / v) ** (-(v + 1) / 2)
+ return (
+ [t, None],
+ [p, None])
+
+
+def select(statistics, benchmark, parameter, statistic):
+ for stat, samples in statistics[benchmark][int(parameter)].iteritems():
+ if stat.name == statistic:
+ return (stat, samples)
+ raise ValueError("Unknown statistic %r" % (statistic,))
+
+
+def main():
+ first = pickle.load(file(sys.argv[1]))
+ second = pickle.load(file(sys.argv[2]))
+
+ stat, first = select(first, *sys.argv[3:])
+ stat, second = select(second, *sys.argv[3:])
+
+ if ttest_1samp(second, stats.mean(first))[1][0] < 0.05:
+ print 'same' # failed to reject the null hypothesis
+ else:
+ print 'different' # rejected the null hypothesis
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100817/21823560/attachment.html>
More information about the calendarserver-changes
mailing list