equal
deleted
inserted
replaced
|
1 .. _profiling: |
|
2 |
|
3 Profiling |
|
4 ========= |
|
5 |
|
6 Profiling of requests by the pyramid debug toolbar can be a little restrictive |
|
7 when a specific url needs thin profiling that includes the whole pyramid |
|
8 dispatch. |
|
9 |
|
10 Pyramid CubicWeb provides facilities to profile requests as a |
|
11 :func:`wsgi middleware <cubicweb.pyramid.profile.wsgi_profile>`, and a few |
|
12 views that facilitate profiling of basic features. |
|
13 |
|
14 The views and the wsgi middleware are activated when the 'profile' option is |
|
15 given. This can be done on the command line |
|
16 (:option:`cubicweb-ctl pyramid --profile`) or in the :ref:`pyramid_settings`. |
|
17 |
|
18 Views |
|
19 ----- |
|
20 |
|
21 The following routes and corresponding views are provided when profiling is on: |
|
22 |
|
23 - ``/_profile/ping``: Reply 'ping' without doing anything else. See also |
|
24 :func:`cubicweb.pyramid.profile.ping`. |
|
25 |
|
26 - ``/_profile/cnx``: Reply 'ping' after getting a cnx. See also |
|
27 :func:`cubicweb.pyramid.profile.cnx`. |
|
28 |
|
29 Typical Usage |
|
30 ------------- |
|
31 |
|
32 Let's say we want to measure the cost of having a ``cnx``. |
|
33 |
|
34 - Start the application with profile enabled: |
|
35 |
|
36 .. code-block:: console |
|
37 |
|
38 $ cubicweb-ctl pyramid --no-daemon --profile --profile-dump-every 100 |
|
39 |
|
40 - Use 'ab' or any other http benchmark tool to throw a lot of requests: |
|
41 |
|
42 .. code-block:: console |
|
43 |
|
44 $ ab -c 1 -n 100 http://localhost:8080/_profile/cnx |
|
45 |
|
46 - Analyse the results. I personnaly fancy SnakeViz_: |
|
47 |
|
48 .. code-block:: console |
|
49 |
|
50 $ snakeviz program.prof |
|
51 |
|
52 .. _SnakeViz: http://jiffyclub.github.io/snakeviz/ |