Commit a6b6ca2d authored by Andreas Jung's avatar Andreas Jung

- Collector #670: applied patch from Dieter Maurer to enhance

        the Zope profiling support
parent 868ca805
......@@ -37,6 +37,9 @@ Zope Changes
Bugs Fixed
- Collector #670: applied patch from Dieter Maurer to enhance
the Zope profiling support
- Collector #651: WebDAV Lock Manager was broken.
- Collector #646: metal:slot was lost during the I18n merge.
......
......@@ -11,7 +11,7 @@
#
##############################################################################
__doc__="""System management components"""
__version__='$Revision: 1.83 $'[11:-2]
__version__='$Revision: 1.84 $'[11:-2]
import sys,os,time,Globals, Acquisition, os, Undo
......@@ -176,15 +176,19 @@ class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit):
manage_profile=DTMLFile('dtml/profile', globals())
def manage_profile_stats(self, sort='time', limit=200):
def manage_profile_stats(self, sort='time', limit=200, stripDirs=1, mode='stats'):
"""Return profile data if available"""
stats=getattr(sys, '_ps_', None)
if stats is None:
return None
output=StringIO()
stdout=sys.stdout
if stripDirs:
from copy import copy; stats= copy(stats)
stats.strip_dirs()
stats.sort_stats(sort)
sys.stdout=output
stats.strip_dirs().sort_stats(sort).print_stats(limit)
getattr(stats,'print_%s' % mode)(limit)
sys.stdout.flush()
sys.stdout=stdout
return output.getvalue()
......
......@@ -3,7 +3,9 @@
<dtml-let sort="REQUEST.get('sort', 'time')"
limit="REQUEST.get('limit', 100)"
stats="manage_profile_stats(sort, limit)">
mode="REQUEST.get('mode', 'stats')"
stripDirs="REQUEST.get('stripDirs', 1)"
stats="manage_profile_stats(sort, limit, stripDirs, mode)">
<dtml-if stats>
<p class="form-help">
Profiling information is generated using the standard Python
......@@ -35,6 +37,19 @@ Python profiler documentation</a>.
</dtml-in>
</select>
</td>
<td><strong>strip Dirs</strong>:
<input type=hidden name="stripDirs:int:default" value="0">
<input type=checkbox name="stripDirs:int" value="1" <dtml-if stripDirs>checked</dtml-if>>
</td>
<td><strong>Mode</strong>:
<select name="mode">
<dtml-in "('stats', 'callees', 'callers',)">
<option value="<dtml-var sequence-item>"<dtml-if
"mode==_['sequence-item']"> selected</dtml-if>><dtml-var
sequence-item>
</dtml-in>
</select>
</td>
<td>
<input type="submit" name="submit" value="Update">
</td>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment