Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def stop(self):
setstatprofile(None)
if process_time:
cpu_time = process_time() - self._start_process_time
self._start_process_time = None
else:
cpu_time = None
self.last_session = ProfilerSession(
frame_records=self.frame_records,
start_time=self._start_time,
duration=time.time() - self._start_time,
sample_count=len(self.frame_records),
program=' '.join(sys.argv),
start_call_stack=self._start_call_stack,
cpu_time=cpu_time,
)
return self.last_session
def load(filename):
with io.open(filename, 'rb' if PY2 else 'r') as f:
return ProfilerSession.from_json(json.load(f))
def from_json(json_dict):
return ProfilerSession(
frame_records=json_dict['frame_records'],
start_time=json_dict['start_time'],
duration=json_dict['duration'],
sample_count=json_dict['sample_count'],
start_call_stack=json_dict['start_call_stack'],
program=json_dict['program'],
cpu_time=json_dict['cpu_time'],
)