[CalendarServer-changes] [6143] CalendarServer/trunk/contrib/performance/benchlib.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 19 18:00:01 PDT 2010


Revision: 6143
          http://trac.macosforge.org/projects/calendarserver/changeset/6143
Author:   exarkun at twistedmatrix.com
Date:     2010-08-19 18:00:01 -0700 (Thu, 19 Aug 2010)
Log Message:
-----------
a couple generally useful functions for benchmark implementations

Added Paths:
-----------
    CalendarServer/trunk/contrib/performance/benchlib.py

Added: CalendarServer/trunk/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.py	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/benchlib.py	2010-08-20 01:00:01 UTC (rev 6143)
@@ -0,0 +1,38 @@
+
+from time import time
+
+from twisted.internet.defer import inlineCallbacks, returnValue
+
+from client.account import CalDAVAccount
+from protocol.url import URL
+
+from stats import Duration
+from httpclient import readBody
+
+def initialize(host, port, user, password, root, principal, calendar):
+    """
+    If the specified calendar exists, delete it.  Then re-create it empty.
+    """
+    account = CalDAVAccount(
+        "%s:%d" % (host, port),
+        user=user, pswd=password,
+        root=root, principal=principal)
+    cal = "/calendars/users/%s/%s/" % (user, calendar)
+    account.session.deleteResource(URL(cal))
+    account.session.makeCalendar(URL(cal))
+    return account
+
+
+ at inlineCallbacks
+def sample(dtrace, samples, agent, paramgen):
+    data = []
+    yield dtrace.start()
+    for i in range(samples):
+        before = time()
+        response = yield agent.request(*paramgen())
+        yield readBody(response)
+        after = time()
+        data.append(after - before)
+    stats = yield dtrace.stop()
+    stats[Duration('urlopen time')] = data
+    returnValue(stats)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100819/816b94c5/attachment.html>


More information about the calendarserver-changes mailing list