-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Add profiling option for backend routes
It produces a HTML report to better identify slow actions in routes.
- Loading branch information
1 parent
3c5c1fd
commit ed34a99
Showing
6 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ dev = [ | |
"aioresponses", | ||
"types-lxml", | ||
"types-croniter", | ||
"pyinstrument", | ||
] | ||
|
||
[tool.black] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
# Profile Backend Routes | ||
|
||
Profiling can be useful if you want to examine the performance of specific | ||
backend routes. | ||
|
||
## Enable profiling | ||
|
||
In the `config.yaml`, set the `logging.profiling` key to `True`. Then, call the | ||
route you want to profile with the `profile` query parameter set to `True`. | ||
|
||
For example, to profile the `/api/v1/metadata` route, you would call | ||
`/api/v1/metadata?profile=True` in the browser. It will return a HTML report. | ||
|
||
!!! info | ||
|
||
Synchronous routes are not supported properly. If you want to profile a | ||
synchronous route, add `async` to the route definition. | ||
|
||
``` | ||
@router.get(...) | ||
def metadata(): | ||
... | ||
``` | ||
|
||
becomes | ||
|
||
``` | ||
@router.get(...) | ||
async def metadata(): | ||
... | ||
``` | ||
|
||
[More Information on GitHub](https://github.com/joerick/pyinstrument/issues/257) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters