# HG changeset patch # User timothy.murphy@nokia.com # Date 1272041195 -3600 # Node ID 5a168ca8e8d4ad1b7c3c7a108362373412e552e1 # Parent c708fcd8e96896473e5bca93d3ef784fc73b29bf# Parent f6aa47076e0ff51052bac3312ae11958a164ec95 Merge diff -r c708fcd8e968 -r 5a168ca8e8d4 sbsv2/raptor/bin/recipestats.py --- a/sbsv2/raptor/bin/recipestats.py Thu Apr 22 19:08:44 2010 +0100 +++ b/sbsv2/raptor/bin/recipestats.py Fri Apr 23 17:46:35 2010 +0100 @@ -20,6 +20,9 @@ import time import __future__ + + + class RecipeStats(object): def __init__(self, name, count, time): self.name=name @@ -39,8 +42,9 @@ self.failtime = 0.0 self.failtypes = {} self.retryfails = 0 + self.hosts = {} - def add(self, starttime, duration, name, status): + def add(self, starttime, duration, name, status, host, phase): if status != BuildStats.STAT_OK: self.failcount += 1 if name in self.failtypes: @@ -58,6 +62,12 @@ else: self.stats[name] = RecipeStats(name,1,duration) + hp=host + if hp in self.hosts: + self.hosts[hp] += 1 + else: + self.hosts[hp] = 1 + def recipe_csv(self): s = '"name", "time", "count"\n' l = sorted(self.stats.values(), key= lambda r: r.time, reverse=True) @@ -65,32 +75,66 @@ s += '"%s",%s,%d\n' % (r.name, str(r.time), r.count) return s + def hosts_csv(self): + s='"host","recipecount"\n' + hs = self.hosts + for h in sorted(hs.keys()): + s += '"%s",%d\n' % (h,hs[h]) + return s import sys import re +import os +from optparse import OptionParser # for parsing command line parameters def main(): + recipe_re = re.compile(".*Making.*?([^\.]+\.[^\.]+)") - f = sys.stdin + parser = OptionParser(prog = "recipestats", + usage = """%prog --help [-b] [-f ]""") + + parser.add_option("-b","--buildhosts",action="store_true",dest="buildhosts_flag", + help="Lists which build hosts were active in each invocation of the build engine and how many recipes ran on each.", default = False) + parser.add_option("-f","--logfile",action="store",dest="logfilename", help="Read from the file, not stdin", default = None) + + + (options, stuff) = parser.parse_args(sys.argv[1:]) + + if options.logfilename is None: + f = sys.stdin + else: + f = open(options.logfilename,"r") + st = BuildStats() - recipe_re = re.compile(".*