mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 02:14:04 +00:00
Add total elapsed time
This commit is contained in:
parent
487fa5317e
commit
6416a11d39
1 changed files with 6 additions and 0 deletions
|
|
@ -296,6 +296,7 @@ class Tracer:
|
|||
'original_trace_functions', []
|
||||
)
|
||||
stack.append(sys.gettrace())
|
||||
self.start_time = datetime_module.datetime.now()
|
||||
sys.settrace(self.trace)
|
||||
|
||||
def __exit__(self, exc_type, exc_value, exc_traceback):
|
||||
|
|
@ -307,6 +308,11 @@ class Tracer:
|
|||
self.target_frames.discard(calling_frame)
|
||||
self.frame_to_local_reprs.pop(calling_frame, None)
|
||||
|
||||
now = (datetime_module.datetime.min + (
|
||||
datetime_module.datetime.now() - self.start_time)).time()
|
||||
now_string = pycompat.time_isoformat(now, timespec='microseconds')
|
||||
self.write('Total elapsed time: {now_string}'.format(**locals()))
|
||||
|
||||
def _is_internal_frame(self, frame):
|
||||
return frame.f_code.co_filename == Tracer.__enter__.__code__.co_filename
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue