[CalendarServer-changes] [6693] CalendarServer/trunk/contrib/performance/loadtest

source_changes at macosforge.org source_changes at macosforge.org
Tue Dec 14 14:24:57 PST 2010


Revision: 6693
          http://trac.macosforge.org/projects/calendarserver/changeset/6693
Author:   exarkun at twistedmatrix.com
Date:     2010-12-14 14:24:53 -0800 (Tue, 14 Dec 2010)
Log Message:
-----------
Rudamentary stats tracking

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/loadtest/ical.py
    CalendarServer/trunk/contrib/performance/loadtest/population.py

Modified: CalendarServer/trunk/contrib/performance/loadtest/ical.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/ical.py	2010-12-14 22:14:03 UTC (rev 6692)
+++ CalendarServer/trunk/contrib/performance/loadtest/ical.py	2010-12-14 22:24:53 UTC (rev 6693)
@@ -21,7 +21,7 @@
 from xml.etree import ElementTree
 ElementTree.QName.__repr__ = lambda self: '<QName %r>' % (self.text,)
 
-from twisted.python.log import err
+from twisted.python.log import err, msg
 from twisted.python.filepath import FilePath
 from twisted.internet.defer import Deferred, inlineCallbacks, returnValue
 from twisted.internet.task import LoopingCall
@@ -65,7 +65,17 @@
 
     def _request(self, method, url, headers, body):
         # XXX Do return code checking here.
-        return self.agent.request(method, url, headers, body)
+        d = self.agent.request(method, url, headers, body)
+        before = self.reactor.seconds()
+        def report(passthrough):
+            after = self.reactor.seconds()
+            # XXX This is time to receive response headers, not time
+            # to receive full response.  Should measure the latter, if
+            # not both.
+            msg(type="request", duration=(after - before), url=url)
+            return passthrough
+        d.addCallback(report)
+        return d
 
 
     def _parsePROPFINDResponse(self, response):

Modified: CalendarServer/trunk/contrib/performance/loadtest/population.py
===================================================================
--- CalendarServer/trunk/contrib/performance/loadtest/population.py	2010-12-14 22:14:03 UTC (rev 6692)
+++ CalendarServer/trunk/contrib/performance/loadtest/population.py	2010-12-14 22:24:53 UTC (rev 6693)
@@ -22,6 +22,7 @@
 
 from itertools import izip
 
+from stats import mean, median, stddev, mad
 from loadtest.ical import SnowLeopard
 
 
@@ -102,13 +103,31 @@
         print 'Now running', self._user, 'clients.'
 
 
+
+class Statistics(object):
+    def __init__(self):
+        self._times = []
+
+    def observe(self, event):
+        if event.get('type') == 'request':
+            self._times.append(event['duration'])
+            if len(self._times) == 200:
+                print 'mean:', mean(self._times)
+                print 'median:', median(self._times)
+                print 'stddev:', stddev(self._times)
+                print 'mad:', mad(self._times)
+                del self._times[:100]
+
     
 def main():
     import random
 
     from twisted.internet import reactor
     from twisted.internet.task import LoopingCall
+    from twisted.python.log import addObserver
 
+    addObserver(Statistics().observe)
+
     r = random.Random()
     r.seed(100)
     populator = Populator(r)
@@ -117,8 +136,11 @@
         populator, parameters, reactor, '127.0.0.1', 8008)
 
     # Uh yea let's see
-    LoopingCall(simulator.add, 1).start(1)
+    call = LoopingCall(simulator.add, 1)
+    call.start(1)
+    reactor.callLater(60, call.stop)
 
+
     reactor.run()
 
 if __name__ == '__main__':
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101214/b7e0b67e/attachment.html>


More information about the calendarserver-changes mailing list