[CalendarServer-changes] [6294] CalendarServer/trunk/contrib/performance/event_move.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 15 06:59:53 PDT 2010
Revision: 6294
http://trac.macosforge.org/projects/calendarserver/changeset/6294
Author: exarkun at twistedmatrix.com
Date: 2010-09-15 06:59:49 -0700 (Wed, 15 Sep 2010)
Log Message:
-----------
Add a benchmark for moving events between calendars
Added Paths:
-----------
CalendarServer/trunk/contrib/performance/event_move.py
Added: CalendarServer/trunk/contrib/performance/event_move.py
===================================================================
--- CalendarServer/trunk/contrib/performance/event_move.py (rev 0)
+++ CalendarServer/trunk/contrib/performance/event_move.py 2010-09-15 13:59:49 UTC (rev 6294)
@@ -0,0 +1,59 @@
+
+from itertools import count, cycle
+from urllib2 import HTTPDigestAuthHandler
+
+from twisted.internet import reactor
+from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.web.client import Agent
+from twisted.web.http_headers import Headers
+
+from httpauth import AuthHandlerAgent
+from httpclient import StringProducer
+
+from benchlib import initialize, sample
+from event import makeEvent
+
+ at inlineCallbacks
+def measure(host, port, dtrace, attendeeCount, samples):
+ user = password = "user01"
+ root = "/"
+ principal = "/"
+
+ # Two calendars between which to move the event.
+ fooCalendar = "event-move-foo-benchmark"
+ barCalendar = "event-move-bar-benchmark"
+
+ authinfo = HTTPDigestAuthHandler()
+ authinfo.add_password(
+ realm="Test Realm",
+ uri="http://%s:%d/" % (host, port),
+ user=user,
+ passwd=password)
+ agent = AuthHandlerAgent(Agent(reactor), authinfo)
+
+ # Set up the calendars first
+ for calendar in [fooCalendar, barCalendar]:
+ yield initialize(
+ agent, host, port, user, password, root, principal, calendar)
+
+ fooURI = 'http://%s:%d/calendars/__uids__/%s/%s/some-event.ics' % (
+ host, port, user, fooCalendar)
+ barURI = 'http://%s:%d/calendars/__uids__/%s/%s/some-event.ics' % (
+ host, port, user, barCalendar)
+
+ # Create the event that will move around
+ headers = Headers({"content-type": ["text/calendar"]})
+ yield agent.request(
+ 'PUT', fooURI, headers, StringProducer(makeEvent(attendeeCount, 1)))
+
+ # Move it around sooo much
+ source = cycle([fooURI, barURI])
+ dest = cycle([barURI, fooURI])
+
+ params = (
+ ('MOVE', source.next(),
+ Headers({"destination": [dest.next()], "overwrite": ["F"]}))
+ for i in count(1))
+
+ samples = yield sample(dtrace, samples, agent, params.next)
+ returnValue(samples)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100915/33d7411e/attachment.html>
More information about the calendarserver-changes
mailing list