Skip to content

Commit

Permalink
📝 Add note about time.perf_counter() in middlewares (fastapi#12095)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo authored Aug 31, 2024
1 parent 5827b92 commit c37f2c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/en/docs/tutorial/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ For example, you could add a custom header `X-Process-Time` containing the time
{!../../../docs_src/middleware/tutorial001.py!}
```

/// tip

Here we use <a href="https://docs.python.org/3/library/time.html#time.perf_counter" class="external-link" target="_blank">`time.perf_counter()`</a> instead of `time.time()` because it can be more precise for these use cases. 🤓

///

## Other middlewares

You can later read more about other middlewares in the [Advanced User Guide: Advanced Middleware](../advanced/middleware.md){.internal-link target=_blank}.
Expand Down

0 comments on commit c37f2c9

Please sign in to comment.