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

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jul 17 13:03:35 CEST 2006


Author: vincent
Date: Mon Jul 17 13:03:27 2006
New Revision: 8443

URL: http://svn.erp5.org?rev=8443&view=rev
Log:
Implement lazyness-based speed handling : Default lazyness is 0, which means maximium speed. This value is supposed to be multiplied by a duration to give the wanted delay between two steps in a test. Valid values are positive or 0 floating point. 0 means maximum speed, 1 means "normal" speed (as defined in the test scenario).
XXX: Hardcode french style decimal notation in csv export.

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=8443&r1=8442&r2=8443&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/runBenchmarks.py (original)
+++ erp5/trunk/utils/erp5mechanize/runBenchmarks.py Mon Jul 17 13:03:27 2006
@@ -70,8 +70,7 @@
     self.url = url
     self.test_result_list = []
     self.lock = Lock()
-    self.min_sleep = 0
-    self.max_sleep = 5
+    self.lazyness = 0
 
   def getResult(self):
     """
@@ -85,11 +84,8 @@
     self.lock.release()
     return res
 
-  def setMaxSleep(self, value):
-    self.sleep_max_len = value
-
-  def setMinSleep(self, value):
-    self.sleep_min_len = value
+  def setLazyness(self, value):
+    self.lazyness = value
 
   def getUrl(self):
     return self.url
@@ -101,14 +97,14 @@
       Waits a random (configurable) ammount of time).
     """
     for test in self.test_list:
+      sleep(randint(2,8) * self.lazyness)
       if MAIN_IS_ALIVE == 0:
         return
       try:
-        result = test['function'](url=self.url, name=self.name, password=self.password)
+        result = test['function'](url=self.url, name=self.name, password=self.password, lazyness=self.lazyness)
         self.test_result_list.append({'id': test['id'], 'step_list': result})
       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(self.min_sleep, self.max_sleep))
 
 def sig_handler(signal_number, stack):
   """
@@ -130,16 +126,19 @@
     return 1
   return 0
 
-def render_csv(file, *args, **kw):
+def render_csv(*args, **kw):
   """
     Return a CSV-rendered version of arguments.
 
     TODO: add escapes
+    XXX: hardcoded french representation : coma separated decimal
   """
   values = [repr(v) for v in args] + [repr(v) for k, v in kw]
-  return ','.join(values)
-
-def main(instance_list, test_list, dresults=None, results=None, load=None, minsleep=None, Maxsleep=None, usercount=None, verbose=0):
+  for pos in xrange(len(values)):
+    values[pos].replace('.', ',')
+  return ';'.join(values)
+
+def main(instance_list, test_list, dresults=None, results=None, load=None, Lazyness=None, usercount=None):
   """
     Create one thread per (instance, user).
     Start threads.
@@ -165,10 +164,8 @@
       user = instance['user_list'][pos]
       thread = BenchmarkThread(url=instance['url'], name=user['name'], password=user['password'], test_list=test_list)
       thread.setName('%s@%s' % (user['name'], instance['url']))
-      if minsleep is not None:
-        thread.setMinSleep(int(minsleep))
-      if Maxsleep is not None:
-        thread.setMaxSleep(int(Maxsleep))
+      if Lazyness is not None:
+        thread.setLazyness(float(Lazyness))
       thread_list.append(thread)
 
   print '%s: Starting %s threads' % (time(), len(thread_list))
@@ -224,7 +221,7 @@
 
 if __name__ == '__main__':
   import getopt
-  possible_arg_list = ('config', 'dresults', 'results', 'load', 'minsleep', 'Maxsleep', 'usercount')
+  possible_arg_list = ('config', 'dresults', 'results', 'load', 'Lazyness', 'usercount')
   possible_opt_list = ('verbose', )
   kw = {}
   args = []




More information about the Erp5-report mailing list