mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Use time.perf_counter() instead of time.time(), closes #1157
This commit is contained in:
parent
dcdfb2c301
commit
810853c5f2
3 changed files with 8 additions and 8 deletions
|
|
@ -37,9 +37,9 @@ def trace(type, **kwargs):
|
|||
if tracer is None:
|
||||
yield
|
||||
return
|
||||
start = time.time()
|
||||
start = time.perf_counter()
|
||||
yield
|
||||
end = time.time()
|
||||
end = time.perf_counter()
|
||||
trace_info = {
|
||||
"type": type,
|
||||
"start": start,
|
||||
|
|
@ -74,7 +74,7 @@ class AsgiTracer:
|
|||
if b"_trace=1" not in scope.get("query_string", b"").split(b"&"):
|
||||
await self.app(scope, receive, send)
|
||||
return
|
||||
trace_start = time.time()
|
||||
trace_start = time.perf_counter()
|
||||
traces = []
|
||||
|
||||
accumulated_body = b""
|
||||
|
|
@ -109,7 +109,7 @@ class AsgiTracer:
|
|||
# We have all the body - modify it and send the result
|
||||
# TODO: What to do about Content-Type or other cases?
|
||||
trace_info = {
|
||||
"request_duration_ms": 1000 * (time.time() - trace_start),
|
||||
"request_duration_ms": 1000 * (time.perf_counter() - trace_start),
|
||||
"sum_trace_duration_ms": sum(t["duration_ms"] for t in traces),
|
||||
"num_traces": len(traces),
|
||||
"traces": traces,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue