[rhmessaging-commits] rhmessaging commits: r3699 - mgmt/trunk/wooly/python/wooly.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Nov 4 15:21:33 EST 2009


Author: justi9
Date: 2009-11-04 15:21:32 -0500 (Wed, 04 Nov 2009)
New Revision: 3699

Modified:
   mgmt/trunk/wooly/python/wooly/bench.py
Log:
Modify cumin-bench output; restore xml checking

Modified: mgmt/trunk/wooly/python/wooly/bench.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/bench.py	2009-11-04 19:24:20 UTC (rev 3698)
+++ mgmt/trunk/wooly/python/wooly/bench.py	2009-11-04 20:21:32 UTC (rev 3699)
@@ -4,6 +4,7 @@
 from collections import defaultdict
 from traceback import print_exc
 from time import time
+from xml.parsers.expat import ParserCreate
 
 from wooly import Session, ClientSession
 
@@ -40,15 +41,20 @@
                 return self.visit(redirect, url, depth + 1)
 
             html = page.render(session)
+
+            if self.print_output:
+                self.print_output_with_line_numbers(html)
+
+            if self.check_output:
+                parser = ParserCreate()
+                parser.Parse(html)
         except KeyboardInterrupt:
             raise
         except:
-            print
             print "Page failure"
 
             profile.print_stack_trace()
 
-            print "URL: %s" % url
             print "Referer: %s" % referer
 
             if self.continue_on_error:
@@ -59,27 +65,16 @@
 
         return (html, profile)
 
-    def parse_html(self, html):
-        try:
-            parser = ParserCreate()
-            parser.Parse(html)
-        except KeyboardInterrupt:
-            raise
-        except:
-            print
+    def print_output_with_line_numbers(self, html):
+        lines = html.split(os.linesep)
 
-            html = html + "[eof]"
+        print "-" * 80
 
-            lines = html.split(os.linesep)
+        for i, line in enumerate(lines):
+            print "%4i %s" % (i + 1, line)
 
-            for i, line in enumerate(lines):
-                print "%4i %s" % (i + 1, line)
+        print "-" * 80
 
-            if self.continue_on_error:
-                print_exc(file=sys.stderr)
-            else:
-                raise
-
     def run(self, max=-1):
         urls = list()
         visited = set()
@@ -91,7 +86,7 @@
         while url is not None:
             visited.add(url)
 
-            print "%4i %-56s" % (count, truncate(url, 56)),
+            print "%i %s" % (count, url)
 
             start = time()
 
@@ -100,13 +95,8 @@
             bytes = len(html)
             millis = (time() - start) * 1000
 
-            print "[%5ib, %4ims]" % (bytes, millis)
+            print "%i [%i bytes, %i millis]" % (count, bytes, millis)
 
-            if self.print_output:
-                print "-" * 80
-                print "  %s" % html.replace("\n", "\n  ")
-                print "-" * 80
-
             profile.print_process_render_asymmetry()
 
             #profile.compute_times()



More information about the rhmessaging-commits mailing list