def save_snapshot(self, id, filename, send_stat=False):
        self.stop_profiling()
    
        if filename is not None:
            filename = self.dump_snapshot(filename)
            print('Snapshot saved to %s' % filename)

        if not send_stat:
            response = ProfilerResponse(id=id, snapshot_filepath=filename)
        else:
            response = ProfilerResponse(id=id)
            stats_to_response(self.get_stats(), response)
            if self.has_tree_stats():
                self.tree_stats_to_response(filename, response)

        self.writer.addCommand(response)
        self.start_profiling()
示例#2
0
    def save_snapshot(self, id, filename, send_stat=False):
        self.stop_profiling()

        if filename is not None:
            filename = self.dump_snapshot(filename)
            print('Snapshot saved to %s' % filename)

        if not send_stat:
            response = ProfilerResponse(id=id, snapshot_filepath=filename)
        else:
            response = ProfilerResponse(id=id)
            stats_to_response(self.get_stats(), response)
            if self.has_tree_stats():
                self.tree_stats_to_response(filename, response)

        self.writer.addCommand(response)
        self.start_profiling()
示例#3
0
from _prof_imports import TBinaryProtocolFactory
from _prof_imports import serialize
from prof_util import stats_to_response

if __name__ == '__main__':

    filename = sys.argv[1]

    m = ProfilerResponse(id=0)

    if filename.endswith('.prof'):
        import vmprof_profiler
        vmprof_profiler.tree_stats_to_response(filename, m)
    else:
        stats = pstats.Stats(filename)
        stats_to_response(stats.stats, m)

    data = serialize(m, TBinaryProtocolFactory())

    # setup stdout to write binary data to it
    if IS_PY3K:
        out = sys.stdout.buffer
    elif sys.platform == 'win32':
        import os, msvcrt
        msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
        out = sys.stdout
    else:
        out = sys.stdout

    out.write(data)
    out.flush()
from _prof_imports import serialize
from prof_util import stats_to_response

if __name__ == "__main__":

    filename = sys.argv[1]

    m = ProfilerResponse(id=0)

    if filename.endswith(".prof"):
        import vmprof_profiler

        vmprof_profiler.tree_stats_to_response(filename, m)
    else:
        stats = pstats.Stats(filename)
        stats_to_response(stats.stats, m)

    data = serialize(m, TBinaryProtocolFactory())

    # setup stdout to write binary data to it
    if IS_PY3K:
        out = sys.stdout.buffer
    elif sys.platform == "win32":
        import os, msvcrt

        msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
        out = sys.stdout
    else:
        out = sys.stdout

    out.write(data)