Changeset 1985
- Timestamp:
- 06/22/08 19:32:32
- Files:
-
- trunk/cherrypy/lib/profiler.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/profiler.py
r1819 r1985 95 95 def stats(self, filename, sortby='cumulative'): 96 96 """stats(index) -> output of print_stats() for the given profile.""" 97 s = pstats.Stats(os.path.join(self.path, filename)) 98 s.strip_dirs() 99 s.sort_stats(sortby) 100 oldout = sys.stdout 101 try: 102 sys.stdout = sio = StringIO.StringIO() 97 sio = StringIO.StringIO() 98 if sys.version_info >= (2, 5): 99 s = pstats.Stats(os.path.join(self.path, filename), stream=sio) 100 s.strip_dirs() 101 s.sort_stats(sortby) 103 102 s.print_stats() 104 finally: 105 sys.stdout = oldout 103 else: 104 # pstats.Stats before Python 2.5 didn't take a 'stream' arg, 105 # but just printed to stdout. So re-route stdout. 106 s = pstats.Stats(os.path.join(self.path, filename)) 107 s.strip_dirs() 108 s.sort_stats(sortby) 109 oldout = sys.stdout 110 try: 111 sys.stdout = sio 112 s.print_stats() 113 finally: 114 sys.stdout = oldout 106 115 response = sio.getvalue() 107 116 sio.close()

