2 # parse the output of "dracut --profile" and produce profiling information
4 # Copyright 2011 Harald Hoyer <harald@redhat.com>
5 # Copyright 2011 Red Hat, Inc. All rights reserved.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 logpats
= r
'[+]+[ \t]+([^ \t]+)[ \t]+([^ \t:]+):[ ]+.*'
28 logpat
= re
.compile(logpats
)
30 groups
= (logpat
.match(line
) for line
in loglines
)
31 tuples
= (g
.groups() for g
in groups
if g
)
38 #print fx - float(oldx[0]), x[0], x[1], oldx[0], oldx[1]
39 if ((fx
- float(oldx
[0])) > 0):
40 yield (fx
- float(oldx
[0]), oldx
[1])
44 colnames
= ('time','line')
46 log
= (dict(zip(colnames
,t
)) for t
in gen_times(tuples
))
48 if __name__
== '__main__':
51 if not x
['line'] in e
:
52 e
[x
['line']] = x
['time']
54 e
[x
['line']] += x
['time']
56 sorted_x
= sorted(e
.iteritems(), key
=operator
.itemgetter(1), reverse
=True)