예제 #1
0
 def stats(self, filename, sortby='cumulative'):
     """:rtype stats(index): output of print_stats() for the given profile.
     """
     sio = BytesIO()
     s = pstats.Stats(os.path.join(self.path, filename), stream=sio)
     s.strip_dirs()
     s.sort_stats(sortby)
     s.print_stats()
     response = sio.getvalue()
     sio.close()
     return response
예제 #2
0
    def stats(self, filename, sortby='cumulative'):
        sio = BytesIO()
        if sys.version_info >= (2, 5):
            s = pstats.Stats(os.path.join(self.path, filename), stream=sio)
            s.strip_dirs()
            s.sort_stats(sortby)
            s.print_stats()
        else:
            s = pstats.Stats(os.path.join(self.path, filename))
            s.strip_dirs()
            s.sort_stats(sortby)
            oldout = sys.stdout
            try:
                sys.stdout = sio
                s.print_stats()
            finally:
                sys.stdout = oldout

        response = sio.getvalue()
        sio.close()
        return response
예제 #3
0
 def stats(self, filename, sortby='cumulative'):
     """:rtype stats(index): output of print_stats() for the given profile.
     """
     sio = BytesIO()
     if sys.version_info >= (2, 5):
         s = pstats.Stats(os.path.join(self.path, filename), stream=sio)
         s.strip_dirs()
         s.sort_stats(sortby)
         s.print_stats()
     else:
         # pstats.Stats before Python 2.5 didn't take a 'stream' arg,
         # but just printed to stdout. So re-route stdout.
         s = pstats.Stats(os.path.join(self.path, filename))
         s.strip_dirs()
         s.sort_stats(sortby)
         oldout = sys.stdout
         try:
             sys.stdout = sio
             s.print_stats()
         finally:
             sys.stdout = oldout
     response = sio.getvalue()
     sio.close()
     return response