mirror of
https://github.com/bugsink/bugsink.git
synced 2026-02-13 17:28:33 -06: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:
|
||||
result.took = (time.time() - t0) * 1000
|
||||
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