os/graphics/fbs/fontandbitmapserver/utils/fbsgroup.py
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
# All rights reserved.
sl@0
     3
# This component and the accompanying materials are made available
sl@0
     4
# under the terms of "Eclipse Public License v1.0"
sl@0
     5
# which accompanies this distribution, and is available
sl@0
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
#
sl@0
     8
# Initial Contributors:
sl@0
     9
# Nokia Corporation - initial contribution.
sl@0
    10
#
sl@0
    11
# Contributors:
sl@0
    12
#
sl@0
    13
# Description:
sl@0
    14
# Groups an ASCII TracViewer trace by the contents of a named parameter. 	
sl@0
    15
#
sl@0
    16
sl@0
    17
import fileinput, string, re, sys, threadname
sl@0
    18
sl@0
    19
# Utility function to group a list by a given regular expression.
sl@0
    20
# returns a dictionary indexed by parameter 1 of the passed in pattern.
sl@0
    21
def groupby(pattern, data):
sl@0
    22
	r = {}
sl@0
    23
	for entry in data:
sl@0
    24
		matched = re.search(pattern, entry)
sl@0
    25
		if matched:
sl@0
    26
			r.setdefault(matched.group(1), []).append(entry)
sl@0
    27
	return r
sl@0
    28
sl@0
    29
# Show the usage if the parameters are not as expected
sl@0
    30
if len(sys.argv) != 3:
sl@0
    31
	print "Usage: fbsgroup <param|-t> <input>"
sl@0
    32
	print "Where:"
sl@0
    33
	print "<param> is a parameter to group by. (-t groups by thread id)"
sl@0
    34
	print "<input> is the ASCII TraceViewer file to be parsed"
sl@0
    35
	sys.exit(1)
sl@0
    36
sl@0
    37
if sys.argv[1] == "-t":
sl@0
    38
	pattern = "(Thread ID:0x.*$)"
sl@0
    39
else:
sl@0
    40
	pattern = "("+sys.argv[1]+"=*\w*);+"
sl@0
    41
	
sl@0
    42
del sys.argv[1]
sl@0
    43
sl@0
    44
# Add thread names to the raw trace
sl@0
    45
rawinput = threadname.addnames(fileinput.input())
sl@0
    46
sl@0
    47
# Group by the parameter supplied on the command line...
sl@0
    48
results = groupby(pattern, rawinput)
sl@0
    49
sl@0
    50
for group, entries in results.items():
sl@0
    51
		print '\n'+group
sl@0
    52
		
sl@0
    53
		# Show a count of the number of CFbsBitmap::xxx function calls
sl@0
    54
		functions = groupby("(CFbsBitmap::\S+:)", entries)
sl@0
    55
		for name, function in functions.items():
sl@0
    56
			print "\t%s %s" % (name, len(function))
sl@0
    57
		
sl@0
    58
		# Show a count of the number of CFbClient::xxx function calls	
sl@0
    59
		functions = groupby("(CFbClient::\S+:)", entries)
sl@0
    60
		for name, function in functions.items():
sl@0
    61
			print "\t%s %s" % (name, len(function))
sl@0
    62
		
sl@0
    63
		# Show a count of the number of RFbsSession::xxx function calls	
sl@0
    64
		functions = groupby("(RFbsSession::\S+:)", entries)
sl@0
    65
		for name, function in functions.items():
sl@0
    66
			print "\t%s %s" % (name, len(function))
sl@0
    67
		
sl@0
    68
		# Show the matching entries for this group
sl@0
    69
		for entry in entries:
sl@0
    70
			print "\t%s" % entry.strip()
sl@0
    71
sl@0
    72
		
sl@0
    73
sl@0
    74
		
sl@0
    75
sl@0
    76