Add request profiling code

To profile a given request, just add ?perfprofile to the url. Instead of
returning the actual results, an HTML presentation of the profiling
results is returned.

This is only enabled when debug mode is enabled.
This commit is contained in:
Flaviu Tamas committed 2020-04-23 19:16:48 -04:00
1 parent 8604b5c105
commit 65b960f0f0
4 files changed
+37 -1

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ Development
environment.rst
virtual_printer.rst
profiling.rst
+20
View File
@@ -0,0 +1,20 @@
.. _sec-request-profiling:
Profiling requests
==================
Once you have a development environment set up, you will need to launch
OctoPrint using ``serve --debug`` as parameters.
At this point, you are able to make the exact same requests as before. To
profile a specific request, just add ``?perfprofile`` or ``&perfprofile`` to the
request parameters. The request will be rendered as usual, but you will receive
an html document with the profiling results instead of the contents of the
response.
Errors
------
If you receive a ``500: Internal Server Error`` and a ``ModuleNotFoundError: No
module named 'pyinstrument'`` in the console, you didn't install development
dependencies. Do that now using ``pip install -e '.[develop]'``.