[Erp5-report] r8965 - /erp5/trunk/utils/erp5mechanize/runBenchmarks.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Aug 1 16:45:43 CEST 2006


Author: vincent
Date: Tue Aug  1 16:45:39 2006
New Revision: 8965

URL: http://svn.erp5.org?rev=8965&view=rev
Log:
Make Repeat argument count repetition, not the initial run. Default is then 0.
Poll more frequently if main thread is runing. This feature is confirmed to wirk.
Add more comments.

Modified:
    erp5/trunk/utils/erp5mechanize/runBenchmarks.py

Modified: erp5/trunk/utils/erp5mechanize/runBenchmarks.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/runBenchmarks.py?rev=8965&r1=8964&r2=8965&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/runBenchmarks.py (original)
+++ erp5/trunk/utils/erp5mechanize/runBenchmarks.py Tue Aug  1 16:45:39 2006
@@ -98,9 +98,6 @@
       Waits a random (configurable) ammount of time).
     """
     for test in self.test_list:
-      if MAIN_IS_ALIVE == 0:
-        sys.stdout.write('Thread %s interrupted.\n' % (self.getName(), ))
-        return
       try:
         result = test['function'](url=self.url,
                                   name=self.name,
@@ -111,13 +108,16 @@
       except: # Don't let server error kill the whole test list - but notify
               # that this test went wrong
         self.test_result_list.append({'id': test['id'], 'step_list': []})
-      sleep(randint(10,20) * self.lazyness)
+      for iter in xrange(10):
+        sleep(2 * self.lazyness)
+        if MAIN_IS_ALIVE == 0:
+          sys.stdout.write('Thread %s interrupted.\n' % (self.getName(), ))
+          return
 
 def sig_handler(signal_number, stack):
   """
     Allows to make threads stop when main process receives a kill signal.
   """
-  # XXX: efficiency not tested
   print 'Killed by signal %s' % (signal_number, )
   MAIN_IS_ALIVE = 0
 
@@ -146,12 +146,17 @@
   return ';'.join(values)
 
 def main(instance_list, test_list, dresults=None, results=None, load=None,
-         Lazyness=None, usercount=None, Repeat=1, zopecount=None):
+         Lazyness=None, usercount=None, Repeat=0, zopecount=None):
   """
     Create one thread per (instance, user).
     Start threads.
     Collect & process results, and write them in result files if asked to.
   """
+  # Handle all parameters.
+  # Delete the parameters when handled so they don't risk to mess up with
+  # global namespace. This habit allows not to care about parameter names
+  # conflicting with standard functions. handling might just mean renaming
+  # to a safe name.
   thread_list = []
   server_load_list = {}
   dresults_file = results_file = load_file = None
@@ -168,15 +173,19 @@
   for repetition in xrange(int(Repeat)): # 0 mean only one execution, 1 means
                                          # two executions, etc.
     temp_list.extend(test_list)
-  test_list = temp_list
+  test_list.extend(temp_list)
   del temp_list
+  del Repeat
+  # Catch all signals who could lead to 'soft' program termination
+  # FIXME: there should be more signals.
   for signal_number in (signal.SIGHUP, signal.SIGSEGV, signal.SIGTERM):
-    # All signal who could lead to 'soft' program termination
     signal.signal(signal_number, sig_handler)
   if zopecount is not None:
     zopecount = int(zopecount)
   else:
     zopecount = len(instance_list)
+  # Get the maximum length of user_list defined on each tested instances.
+  # Used for load balancing.
   maximum_length = 0
   for pos in xrange(zopecount):
     instance = instance_list[pos]
@@ -185,14 +194,20 @@
     usercount = int(usercount)
   else:
     usercount = maximum_length
+  # Instanciate threads.
+  # A threads represents a user on an instance. It will execute the whole
+  # given test suite in the girven order.
+  # User number is balanced among instances. For example 4 users on 3 zope
+  # will make the first zope handle 2 users and the other zopes will handle
+  # one user each. With 5 users, the second zope will get 2 users, etc.
   for user_pos in xrange(maximum_length):
     for instance_pos in xrange(zopecount):
       if len(thread_list) >= usercount:
         break
       instance = instance_list[instance_pos]
-      try:
+      if user_pos < len(instance['user_list']):
         user = instance['user_list'][user_pos]
-      except IndexError:
+      else:
         user = None
       if user is not None:
         thread = BenchmarkThread(url=instance['url'], name=user['name'],




More information about the Erp5-report mailing list