author | timothy.murphy@nokia.com |
Sun, 06 Dec 2009 10:38:55 +0000 | |
branch | wip |
changeset 87 | 01cb4707f979 |
child 88 | b5820d0f3a1c |
child 90 | 608b444a9759 |
permissions | -rw-r--r-- |
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
|
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
|
2 |
# 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
|
3 |
# 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
|
4 |
# 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
|
5 |
# 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
|
6 |
# 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
|
7 |
# 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
|
8 |
# |
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 |
# 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
|
10 |
# 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
|
11 |
# |
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 |
# 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
|
13 |
# |
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 |
# 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
|
15 |
# |
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 |
# 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
|
17 |
# 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
|
18 |
|
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 |
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
|
20 |
|
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 |
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
|
22 |
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
|
23 |
|
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 |
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
|
26 |
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
|
27 |
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
|
28 |
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
|
29 |
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
|
30 |
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
|
31 |
|
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 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
|
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 |
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
|
41 |
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
|
42 |
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
|
43 |
|
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 |
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
|
45 |
(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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
|
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 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
|
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 |
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
|
59 |
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
|
60 |
|
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 |
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
|
62 |
|
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 |
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
|
64 |
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
|
65 |
|
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 |
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
|
67 |
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
|
68 |
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
|
69 |
|
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 |
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
|
71 |
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
|
72 |
|
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 |
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
|
75 |
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
|
76 |
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
|
77 |
|
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 |
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
|
79 |
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
|
80 |
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
|
81 |
|
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 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
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
|
88 |
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
|
89 |
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
|
90 |
|
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 |
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
|
92 |
|
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 |
#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
|
94 |
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
|
95 |
|
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 |
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
|
97 |
|
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 |
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
|
99 |
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
|
100 |
|
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 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
|
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 |
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
|
107 |
|
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 |
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
|
109 |
|
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 |
if __name__ == '__main__': main() |