How to use the pyinstrument.session.ProfilerSession function in pyinstrument

To help you get started, we’ve selected a few pyinstrument examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joerick / pyinstrument / pyinstrument / profiler.py View on Github external
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
github joerick / pyinstrument / pyinstrument / session.py View on Github external
def load(filename):
        with io.open(filename, 'rb' if PY2 else 'r') as f:
            return ProfilerSession.from_json(json.load(f))
github joerick / pyinstrument / pyinstrument / session.py View on Github external
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'],
        )