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