from repoze.profile.profiler import AccumulatingProfileMiddleware
application = AccumulatingProfileMiddleware(application, log_filename=
    '/path/to/logs/profile.log', discard_first_request=True,
    flush_at_shutdown=True, path='/_profile')
benchmarking django apps