sbsv2/raptor/bin/recipestats.py
author raptorbot <raptorbot@systemstesthead.symbian.intra>
Wed, 09 Dec 2009 13:46:46 +0000
branchwip
changeset 91 de6993a90461
parent 90 608b444a9759
child 92 6ebd8f14df45
permissions -rwxr-xr-x
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
90
608b444a9759 Recipestats summarises recipe times by type from a log.
timothy.murphy@nokia.com
parents: 87
diff changeset
     1
#!/usr/bin/env python
87
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     2
#
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     3
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     4
# All rights reserved.
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     5
# This component and the accompanying materials are made available
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     6
# under the terms of the License "Eclipse Public License v1.0"
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     7
# which accompanies this distribution, and is available
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     8
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
     9
#
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    10
# Initial Contributors:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    11
# Nokia Corporation - initial contribution.
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    12
#
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    13
# Contributors:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    14
#
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    15
# Description: 
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    16
# 
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    17
# display summary information about recipes from raptor logs
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    18
# e.g. total times and so on.
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    19
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    20
import time
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    21
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    22
class RecipeStats(object):
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    23
	STAT_OK = 0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    24
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    25
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    26
	def __init__(self):
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    27
		self.stats = {}
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    28
		self.failcount = 0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    29
		self.failtime = 0.0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    30
		self.failtypes = {}
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    31
		self.retryfails = 0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    32
		
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    33
	def add(self, starttime, duration, name, status):
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    34
		if status != RecipeStats.STAT_OK:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    35
			self.failcount += 1
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    36
			if name in self.failtypes:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    37
				self.failtypes[name] += 1
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    38
			else:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    39
				self.failtypes[name] = 1
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    40
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    41
			if status == 128:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    42
				self.retryfails += 1
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    43
			return
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    44
			
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    45
		if name in self.stats:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    46
			(count, time) = self.stats[name]
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    47
			self.stats[name] = (count + 1, time + duration)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    48
		else:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    49
			self.stats[name] = (1,duration)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    50
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    51
	def recipe_csv(self):
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    52
		s = "# name, time, count\n"
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    53
		for (name,(count,time)) in self.stats.iteritems():
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    54
			s += '"%s",%s,%d\n' % (name, str(time), count)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    55
		return s
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    56
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    57
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    58
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    59
import sys
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    60
import re
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    61
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    62
def main():
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    63
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    64
	f = sys.stdin
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    65
	st = RecipeStats()
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    66
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    67
	recipe_re = re.compile(".*<recipe name='([^']+)'.*")
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    68
	time_re = re.compile(".*<time start='([0-9]+\.[0-9]+)' *elapsed='([0-9]+\.[0-9]+)'.*")
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    69
	status_re = re.compile(".*<status exit='([^']*)'.*")
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    70
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    71
	alternating = 0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    72
	start_time = 0.0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    73
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    74
	
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    75
	for l in f.xreadlines():
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    76
		l2 = l.rstrip("\n")
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    77
		rm = recipe_re.match(l2)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    78
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    79
		if rm is not None:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    80
			rname = rm.groups()[0]
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    81
			continue
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    82
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    83
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    84
		tm = time_re.match(l2)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    85
		if tm is not None:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    86
			s = float(tm.groups()[0])
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    87
			elapsed = float(tm.groups()[1])
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    88
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    89
			if start_time == 0.0:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    90
				start_time = s
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    91
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    92
			s -= start_time
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    93
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    94
			#print s,elapsed
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    95
			continue
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    96
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    97
		sm = status_re.match(l2)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    98
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
    99
		if sm is None:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   100
			continue
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   101
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   102
		if sm.groups()[0] == 'ok':
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   103
			status = 0
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   104
		else:
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   105
			status = int(sm.groups()[0])
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   106
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   107
		st.add(s, elapsed, rname, status)
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   108
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   109
	print st.recipe_csv()
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   110
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   111
01cb4707f979 Added a script for finding out how time each class of recipes took in the build
timothy.murphy@nokia.com
parents:
diff changeset
   112
if __name__ == '__main__': main()