[Erp5-report] r9690 - /erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Sep 6 12:01:50 CEST 2006


Author: vincent
Date: Wed Sep  6 12:01:49 2006
New Revision: 9690

URL: http://svn.erp5.org?rev=9690&view=rev
Log:
New script which draws in ascii art a repartition of each step response time within 10 time slices, from 0 to the maximum time the step ever took.

Added:
    erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py   (with props)

Added: erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py?rev=9690&view=auto
==============================================================================
--- erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py (added)
+++ erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py Wed Sep  6 12:01:49 2006
@@ -1,0 +1,89 @@
+#!/usr/bin/python
+##############################################################################
+#
+# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Vincent Pelletier <vincent at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+import sys
+import getopt
+
+def parse_csv_line(line, sep):
+  line = line.replace('\n','')
+  item_list = line.split(sep)
+  for pos in xrange(len(item_list)):
+    item = item_list[pos]
+    if item[0] == "'":
+      item = item[1:]
+    if item[-1] == "'":
+      item = item[:-1]
+    item_list[pos] = item
+  return item_list
+
+def output_csv(fields=[], separator=','):
+  sys.stdout.write(separator.join([repr(v) for v in fields]))
+  sys.stdout.write('\n')
+
+try:
+  opt_list, arg_list = getopt.getopt(sys.argv[1:], '', ['csv_separator='])
+except getopt.error, msg:
+  print 'Error: %s' % (msg, )
+  print \
+'''Synopsis:
+  %s [--csv_separator=char] [file [...]]
+''' % (sys.argv[0], )
+  sys.exit(2)
+
+csv_separator = ','
+ignore_first_run = False
+for o, a in opt_list:
+  if o == '--csv_separator':
+    csv_separator = a
+
+step_list = {}
+for filename in arg_list:
+  csv = open(filename)
+  line_list = csv.readlines()
+  for line in line_list:
+    field_list = parse_csv_line(line, csv_separator)
+    if len(field_list) != 5:
+      #raise KeyError, '%s has %s fields, 5 expected.' % (filename, len(field_list))
+      print 'Ignoring line %s' % (line, )
+      continue
+    else:
+      key = '%s:%s' % (field_list[1], field_list[2])
+      if not step_list.has_key(key):
+        step_list[key] = []
+      step_list[key].append(float(field_list[4])-float(field_list[3]))
+  csv.close()
+
+for k, v in step_list.items():
+  print k
+  repartition = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+  maxduration = max(v)
+  rangewidth = maxduration / (len(repartition) - 1)
+  for value in v:
+    repartition[int(value/rangewidth)] += 1
+  for pos in xrange(len(repartition)):
+    print 't<%0.2f\t: %s' % (rangewidth * (pos + 1), '#' * repartition[pos])

Propchange: erp5/trunk/utils/erp5mechanize/timerepartitionperstep.py
------------------------------------------------------------------------------
    svn:executable = *




More information about the Erp5-report mailing list