From: Dom Date: Tue, 6 Aug 2024 13:46:39 +0000 (+0100) Subject: edit middleware docs code sample to use perf_counter as a timer X-Git-Tag: 0.112.3~36^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ff5da8bf2b8bfe895e4621f630e9fc3f2c434f4;p=thirdparty%2Ffastapi%2Ffastapi.git edit middleware docs code sample to use perf_counter as a timer --- diff --git a/docs_src/middleware/tutorial001.py b/docs_src/middleware/tutorial001.py index 6bab3410a6..e65a7dade1 100644 --- a/docs_src/middleware/tutorial001.py +++ b/docs_src/middleware/tutorial001.py @@ -7,8 +7,8 @@ app = FastAPI() @app.middleware("http") async def add_process_time_header(request: Request, call_next): - start_time = time.time() + start_time = time.perf_counter() response = await call_next(request) - process_time = time.time() - start_time + process_time = time.perf_counter() - start_time response.headers["X-Process-Time"] = str(process_time) return response