equal
deleted
inserted
replaced
1 """ Tools for profiling. |
1 """ Tools for profiling. |
2 |
2 |
3 See :ref:`profiling`.""" |
3 See :ref:`profiling`.""" |
|
4 from __future__ import print_function |
|
5 |
4 import cProfile |
6 import cProfile |
5 import itertools |
7 import itertools |
|
8 |
6 from pyramid.view import view_config |
9 from pyramid.view import view_config |
7 |
10 |
8 |
11 |
9 @view_config(route_name='profile_ping') |
12 @view_config(route_name='profile_ping') |
10 def ping(request): |
13 def ping(request): |
51 try: |
54 try: |
52 return app(environ, start_response) |
55 return app(environ, start_response) |
53 finally: |
56 finally: |
54 profile.disable() |
57 profile.disable() |
55 if not counter.next() % dump_every: |
58 if not counter.next() % dump_every: |
56 print "Dump profile stats to %s" % filename |
59 print("Dump profile stats to %s" % filename) |
57 profile.create_stats() |
60 profile.create_stats() |
58 profile.dump_stats(filename) |
61 profile.dump_stats(filename) |
59 |
62 |
60 return application |
63 return application |