def createInboxWithManyMessages(): siteStore, userStore = initializeStore() # Deliver one message by way of the MIME parser. delivery = IMIMEDelivery(userStore) receiver = delivery.createMIMEReceiver(u'benchmark_nextmsg') receiver.feedFileNow( FilePath(__file__).sibling('messages').child( 'Domain registration order #1487387.eml').open()) message = receiver.message flags = itertools.cycle([ [False, False, False, False, False], [True, False, False, False, False], [False, True, False, False, False], [False, False, True, False, False], [False, False, False, True, False], [False, False, False, False, True]]) # Now make a ton of new Message objects and re-use the same implementation # object for each of them (otherwise this would take a month to finish). def deliverSome(): read, archived, trash, deferred, spam = flags.next() for i in xrange(N_MESSAGES): Message( store=userStore, # source=message.source, # sentWhen=message.sentWhen + timedelta(seconds=i), receivedWhen=message.receivedWhen + timedelta(seconds=i), # sender=message.sender, # senderDisplay=message.senderDisplay, # recipient=message.recipient, # subject=message.subject, # attachments=message.attachments, read=read, archived=archived, trash=trash, deferred=deferred, spam=False, # trained=message.trained, # impl=message.impl ) for i in xrange(N_LOOPS): userStore.transact(deliverSome) # Setup is complete: there are a ton of messages in the database. Now do # some stuff with an Inbox object. inbox = userStore.findUnique(Inbox) return inbox
def createInboxWithManyMessages(): siteStore, userStore = initializeStore() # Deliver one message by way of the MIME parser. delivery = IMIMEDelivery(userStore) receiver = delivery.createMIMEReceiver(u'benchmark_nextmsg') receiver.feedFileNow( FilePath(__file__).sibling('messages').child( 'Domain registration order #1487387.eml').open()) message = receiver.message flags = itertools.cycle([[False, False, False, False, False], [True, False, False, False, False], [False, True, False, False, False], [False, False, True, False, False], [False, False, False, True, False], [False, False, False, False, True]]) # Now make a ton of new Message objects and re-use the same implementation # object for each of them (otherwise this would take a month to finish). def deliverSome(): read, archived, trash, deferred, spam = flags.next() for i in xrange(N_MESSAGES): Message( store=userStore, # source=message.source, # sentWhen=message.sentWhen + timedelta(seconds=i), receivedWhen=message.receivedWhen + timedelta(seconds=i), # sender=message.sender, # senderDisplay=message.senderDisplay, # recipient=message.recipient, # subject=message.subject, # attachments=message.attachments, read=read, archived=archived, trash=trash, deferred=deferred, spam=False, # trained=message.trained, # impl=message.impl ) for i in xrange(N_LOOPS): userStore.transact(deliverSome) # Setup is complete: there are a ton of messages in the database. Now do # some stuff with an Inbox object. inbox = userStore.findUnique(Inbox) return inbox
def main(): s, userStore = initializeStore() g = grabber.POP3Grabber(store=userStore, username=u"testuser", password=u"password", domain=u"127.0.0.1", port=12345) scheduler.IScheduler(userStore).schedule(g, extime.Time()) StoppingMessageFilter(store=userStore, totalMessages=TOTAL_MESSAGES).installOn(userStore) pop3server = filepath.FilePath(__file__).sibling("pop3server.tac") os.system("twistd -y " + pop3server.path) benchmark.start() os.system("axiomatic -d wholesystem.axiom start -n") benchmark.stop() os.system("kill `cat twistd.pid`")
def main(): s, userStore = initializeStore() MailTransferAgent(store=userStore).installOn(userStore) MailTransferAgent(store=s, portNumber=12345).installOn(s) StoppingMessageFilter(store=userStore, totalMessages=TOTAL_MESSAGES).installOn(userStore) smtpclient = FilePath(__file__).sibling('smtpclient.tac') system("SMTP_SERVER_PORT=%d " "SMTP_MESSAGE_COUNT=%d " "SMTP_RECIPIENT_ADDRESS=%s " "twistd -y %s" % (12345, TOTAL_MESSAGES, "testuser@localhost", smtpclient.path)) start() system("axiomatic -d wholesystem.axiom start -n") stop() system("kill `cat twistd.pid`")
def main(): s, userStore = initializeStore() g = grabber.POP3Grabber( store=userStore, username=u"testuser", password=u"password", domain=u"127.0.0.1", port=12345) scheduler.IScheduler(userStore).schedule(g, extime.Time()) StoppingMessageFilter(store=userStore, totalMessages=TOTAL_MESSAGES).installOn(userStore) pop3server = filepath.FilePath(__file__).sibling("pop3server.tac") os.system("twistd -y " + pop3server.path) benchmark.start() os.system("axiomatic -d wholesystem.axiom start -n") benchmark.stop() os.system("kill `cat twistd.pid`")
def main(): s, userStore = initializeStore() MailTransferAgent(store=userStore).installOn(userStore) MailTransferAgent(store=s, portNumber=12345).installOn(s) StoppingMessageFilter(store=userStore, totalMessages=TOTAL_MESSAGES).installOn(userStore) smtpclient = FilePath(__file__).sibling('smtpclient.tac') system("SMTP_SERVER_PORT=%d " "SMTP_MESSAGE_COUNT=%d " "SMTP_RECIPIENT_ADDRESS=%s " "twistd -y %s" % (12345, TOTAL_MESSAGES, "testuser@localhost", smtpclient.path)) start() system("axiomatic -d wholesystem.axiom start -n") stop() system("kill `cat twistd.pid`")
def main(): s, userStore = benchmark_initialize.initializeStore() g = grabber.POP3Grabber( store=userStore, username=u'testuser', password=u'password', domain=u'127.0.0.1', port=12345) def createPOP3UIDs(): msg = Message() for i in xrange(10000 * FACTOR): g.markSuccess(str(i), msg) userStore.transact(createPOP3UIDs) def filterPOP3UIDs(): for i in xrange(20000 * FACTOR / 100): r = xrange(i * 100, i * 100 + 100) g.shouldRetrieve(list(enumerate(map(str, r)))) benchmark.start() userStore.transact(filterPOP3UIDs) benchmark.stop()
def main(): s, userStore = benchmark_initialize.initializeStore() g = grabber.POP3Grabber(store=userStore, username=u'testuser', password=u'password', domain=u'127.0.0.1', port=12345) def createPOP3UIDs(): msg = Message() for i in xrange(10000 * FACTOR): g.markSuccess(str(i), msg) userStore.transact(createPOP3UIDs) def filterPOP3UIDs(): for i in xrange(20000 * FACTOR / 100): r = xrange(i * 100, i * 100 + 100) g.shouldRetrieve(list(enumerate(map(str, r)))) benchmark.start() userStore.transact(filterPOP3UIDs) benchmark.stop()