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

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Nov 9 10:05:17 EST 2009


Author: justi9
Date: 2009-11-09 10:05:16 -0500 (Mon, 09 Nov 2009)
New Revision: 3702

Modified:
   mgmt/trunk/wooly/python/wooly/__init__.py
   mgmt/trunk/wooly/python/wooly/bench.py
Log:
 * Print min/max/average page load times in cumin-bench

 * Optimize query var look up when marshalling session state


Modified: mgmt/trunk/wooly/python/wooly/__init__.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/__init__.py	2009-11-05 18:18:42 UTC (rev 3701)
+++ mgmt/trunk/wooly/python/wooly/__init__.py	2009-11-09 15:05:16 UTC (rev 3702)
@@ -10,7 +10,7 @@
 from time import gmtime
 from uuid import uuid4
 
-from profile import *
+from wooly.profile import *
 from resources import ResourceFinder, StringCatalog
 from util import *
 
@@ -541,7 +541,6 @@
     def expire_cookie(self, name):
         self.set_cookie(name, "", datetime(*gmtime(1)[0:6]))
 
-    # This is the biggest hotspot in cumin-bench profiling
     def get(self, key):
         if key in self.values_by_path:
             value = self.values_by_path[key]
@@ -583,37 +582,34 @@
         params = self.page.get_page_parameters(self)
         vars = list()
 
+        values_by_path = self.gather_values()
+
         for param in params:
             key = param.path
+            value = values_by_path.get(key)
 
-            if param.is_collection:
-                collection = self.get(key)
-
-                if collection:
-                    for value in collection:
-                        svalue = quote(param.marshal(value))
-                        vars.append("%s=%s" % (key, svalue))
-            else:
-                #value = self.get(key)
-
-                # Inlined below saving about a second in a
-                # 1000-hit profile
-
-                if key in self.values_by_path:
-                    value = self.values_by_path[key]
-                elif self.trunk:
-                    value = self.trunk.get(key)
-                else:
-                    value = None
-
-                default = param.get_default(self)
-
-                if value not in (default, None):
+            if value is not None:
+                if param.is_collection:
+                    for item in value:
+                        sitem = quote(param.marshal(item))
+                        vars.append("%s=%s" % (key, sitem))
+                elif value != param.get_default(self):
                     svalue = quote(param.marshal(value))
                     vars.append("%s=%s" % (key, svalue))
 
         return separator.join(vars)
 
+    def gather_values(self):
+        if self.trunk is None:
+            return self.values_by_path
+        else:
+            values_by_path = dict()
+
+            values_by_path.update(self.trunk.gather_values())
+            values_by_path.update(self.values_by_path)
+
+            return values_by_path
+
     def unmarshal(cls, app, string):
         elems = string.split("?")
 

Modified: mgmt/trunk/wooly/python/wooly/bench.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/bench.py	2009-11-05 18:18:42 UTC (rev 3701)
+++ mgmt/trunk/wooly/python/wooly/bench.py	2009-11-09 15:05:16 UTC (rev 3702)
@@ -75,9 +75,10 @@
 
         print "-" * 80
 
-    def run(self, max=-1):
+    def run(self, max_count=-1):
         urls = list()
         visited = set()
+        times = list()
 
         count = 1
         referer = None
@@ -92,11 +93,15 @@
 
             html, profile = self.visit(url, referer, 0)
 
+            end = time()
+
             bytes = len(html)
-            millis = (time() - start) * 1000
+            millis = (end - start) * 1000
 
             print "%i [%i bytes, %i millis]" % (count, bytes, millis)
 
+            times.append(millis)
+
             profile.print_process_render_asymmetry()
 
             #profile.compute_times()
@@ -104,7 +109,7 @@
             #profile.print_process_calls()
             #profile.print_render_calls()
 
-            if count == max:
+            if count == max_count:
                 break
 
             count += 1
@@ -120,6 +125,10 @@
 
         self.print_profile()
 
+        args = (min(times), max(times), sum(times) / float(len(times)))
+
+        print "[min %.3f, max %.3f, avg %.3f]" % args
+
     def print_profile(self):
         render_times_by_widget = defaultdict(list)
 



More information about the rhmessaging-commits mailing list