Back to index

moin  1.9.0~rc2
raw_wsgi_bench.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 """
00003     MoinMoin - raw_wsgi_bench
00004 
00005     @copyright: 2008 MoinMoin:FlorianKrupicka
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 import time, itertools, sys, os
00009 
00010 from werkzeug.test import Client
00011 
00012 from MoinMoin.wsgiapp import application
00013 
00014 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'tests'))
00015 
00016 RUNS = 100
00017 RUNS_MARKER = RUNS / 10
00018 DOTS_MARKER = RUNS_MARKER / 5
00019 
00020 PAGES = ('FrontPage', 'HelpOnMoinWikiSyntax', 'RecentChanges')
00021 
00022 client = Client(application)
00023 
00024 for page in PAGES:
00025     print '=== Run with page "%s" ===' % page
00026     print 'Running %i WSGI-requests:' % RUNS
00027     timing = time.time()
00028     for run in xrange(RUNS):
00029         appiter, status, headers = client.get('/%s' % page)
00030         #result = ''.join(appiter)
00031         if ((run + 1) % RUNS_MARKER == 0):
00032             sys.stdout.write('%i' % (run + 1))
00033         elif ((run + 1) % DOTS_MARKER == 0):
00034             sys.stdout.write('.')
00035     timing = time.time() - timing
00036 
00037     print
00038     print 'Finished %i WSGI-requests in %.2f seconds' % (RUNS, timing)
00039     print 'Time per request: %.4f seconds' % (timing / RUNS)
00040     print 'Requests per second: %.2f' % (RUNS / timing)