mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Add performance context_manager for timings
was useful during debugging
This commit is contained in:
@@ -31,3 +31,18 @@ def time_and_query_count():
|
|||||||
finally:
|
finally:
|
||||||
result.took = (time.time() - t0) * 1000
|
result.took = (time.time() - t0) * 1000
|
||||||
result.count = len(connection.queries) - pre
|
result.count = len(connection.queries) - pre
|
||||||
|
|
||||||
|
|
||||||
|
class Time:
|
||||||
|
def __init__(self):
|
||||||
|
self.took = None
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def time_it():
|
||||||
|
result = Time()
|
||||||
|
t0 = time.time()
|
||||||
|
try:
|
||||||
|
yield result
|
||||||
|
finally:
|
||||||
|
result.took = (time.time() - t0) * 1000
|
||||||
|
|||||||
Reference in New Issue
Block a user