[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/utilities/runurl.py
Merged from trunk 25977:
Jim Fulton
jim at zope.com
Fri Jul 2 17:01:58 EDT 2004
Log message for revision 26076:
Merged from trunk 25977:
Changd to disable garbage collection while executing requests when
profiling to avoid adding variability to profilling results due to gc.
-=-
Modified: Zope3/branches/ZopeX3-3.0/utilities/runurl.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/utilities/runurl.py 2004-07-02 21:00:18 UTC (rev 26075)
+++ Zope3/branches/ZopeX3-3.0/utilities/runurl.py 2004-07-02 21:01:58 UTC (rev 26076)
@@ -69,7 +69,7 @@
$Id: runurl.py,v 1.6 2003/11/21 17:12:47 jim Exp $
"""
-import sys, os, getopt
+import sys, os, getopt, gc
def main(argv=None):
global app, path, basic, run, stdin, env, debugger
@@ -142,7 +142,7 @@
_mainrun(debugger, path, basic, 1, stdin, env)
if profilef or hotshotf:
- cmd = "_mainrun(debugger, path, basic, run, stdin, env)"
+ cmd = "_mainrun(debugger, path, basic, run, stdin, env, True)"
if profilef:
import profile
profile.run(cmd, profilef)
@@ -164,7 +164,10 @@
_mainrun(debugger, path, basic, run, stdin, env)
resultfmt = "elapsed: %.4f, cpu=%.4f, status=%s"
-def _mainrun(debugger, path, basic, run, stdin, environment):
+def _mainrun(debugger, path, basic, run, stdin, environment, profile=False):
+ if profile:
+ threshold = gc.get_threshold()
+ gc.disable()
if run:
es = []
cs = []
@@ -173,6 +176,8 @@
environment=environment)
es.append(e)
cs.append(c)
+ if profile:
+ collect()
print resultfmt % (e, c, status)
if run > 1:
@@ -185,8 +190,21 @@
else:
print resultfmt % debugger.publish(path=path, basic=basic, stdin=stdin,
environment=environment)
+ if profile:
+ gc.set_threshold(*threshold)
+ gc.enable()
+def collect():
+ #gc.collect()
+ gc.enable()
+ gc.set_threshold(1)
+ l = [1]
+ l = l * 10
+ l = None
+ gc.disable()
+
+
def _doimport(script, src):
try:
import zope.app
More information about the Zope3-Checkins
mailing list