[Zope-CVS] CVS: Products/ZCTextIndex/tests - mailtest.py:1.1.2.21

Fred L. Drake, Jr. fdrake@acm.org
Mon, 13 May 2002 11:31:26 -0400


Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv28440

Modified Files:
      Tag: TextIndexDS9-branch
	mailtest.py 
Log Message:
Added option to run profiling with the old profiler.

=== Products/ZCTextIndex/tests/mailtest.py 1.1.2.20 => 1.1.2.21 ===
     mbox_path = None
     profile = None
-    clean = 0
+    old_profile = None
     try:
         opts, args = getopt.getopt(sys.argv[1:], 'vn:p:i:q:b:xt:',
-                                   ['profile='])
+                                   ['profile=', 'old-profile='])
     except getopt.error, msg:
         usage(msg)
     if len(args) != 1:
@@ -213,11 +213,20 @@
             TXN_SIZE = int(v)
         elif o == '--profile':
             profile = v
+        elif o == '--old-profile':
+            old_profile = v
     fs_path, = args
     if profile:
         import hotshot
         profiler = hotshot.Profile(profile, lineevents=1, linetimings=1)
         profiler.runcall(main, fs_path, mbox_path, query_str)
         profiler.close()
+    elif old_profile:
+        import profile, pstats
+        profiler = profile.Profile()
+        profiler.runcall(main, fs_path, mbox_path, query_str)
+        profiler.dump_stats(old_profile)
+        stats = pstats.Stats(old_profile)
+        stats.strip_dirs().sort_stats('time').print_stats(20)
     else:
         main(fs_path, mbox_path, query_str)