1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/fbs/fontandbitmapserver/utils/fbsgroup.py Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,76 @@
1.4 +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +# All rights reserved.
1.6 +# This component and the accompanying materials are made available
1.7 +# under the terms of "Eclipse Public License v1.0"
1.8 +# which accompanies this distribution, and is available
1.9 +# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +#
1.11 +# Initial Contributors:
1.12 +# Nokia Corporation - initial contribution.
1.13 +#
1.14 +# Contributors:
1.15 +#
1.16 +# Description:
1.17 +# Groups an ASCII TracViewer trace by the contents of a named parameter.
1.18 +#
1.19 +
1.20 +import fileinput, string, re, sys, threadname
1.21 +
1.22 +# Utility function to group a list by a given regular expression.
1.23 +# returns a dictionary indexed by parameter 1 of the passed in pattern.
1.24 +def groupby(pattern, data):
1.25 + r = {}
1.26 + for entry in data:
1.27 + matched = re.search(pattern, entry)
1.28 + if matched:
1.29 + r.setdefault(matched.group(1), []).append(entry)
1.30 + return r
1.31 +
1.32 +# Show the usage if the parameters are not as expected
1.33 +if len(sys.argv) != 3:
1.34 + print "Usage: fbsgroup <param|-t> <input>"
1.35 + print "Where:"
1.36 + print "<param> is a parameter to group by. (-t groups by thread id)"
1.37 + print "<input> is the ASCII TraceViewer file to be parsed"
1.38 + sys.exit(1)
1.39 +
1.40 +if sys.argv[1] == "-t":
1.41 + pattern = "(Thread ID:0x.*$)"
1.42 +else:
1.43 + pattern = "("+sys.argv[1]+"=*\w*);+"
1.44 +
1.45 +del sys.argv[1]
1.46 +
1.47 +# Add thread names to the raw trace
1.48 +rawinput = threadname.addnames(fileinput.input())
1.49 +
1.50 +# Group by the parameter supplied on the command line...
1.51 +results = groupby(pattern, rawinput)
1.52 +
1.53 +for group, entries in results.items():
1.54 + print '\n'+group
1.55 +
1.56 + # Show a count of the number of CFbsBitmap::xxx function calls
1.57 + functions = groupby("(CFbsBitmap::\S+:)", entries)
1.58 + for name, function in functions.items():
1.59 + print "\t%s %s" % (name, len(function))
1.60 +
1.61 + # Show a count of the number of CFbClient::xxx function calls
1.62 + functions = groupby("(CFbClient::\S+:)", entries)
1.63 + for name, function in functions.items():
1.64 + print "\t%s %s" % (name, len(function))
1.65 +
1.66 + # Show a count of the number of RFbsSession::xxx function calls
1.67 + functions = groupby("(RFbsSession::\S+:)", entries)
1.68 + for name, function in functions.items():
1.69 + print "\t%s %s" % (name, len(function))
1.70 +
1.71 + # Show the matching entries for this group
1.72 + for entry in entries:
1.73 + print "\t%s" % entry.strip()
1.74 +
1.75 +
1.76 +
1.77 +
1.78 +
1.79 +