net/tulip/xircom_cb.c: remove superfulous priv assignment
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / scripts / bloat-o-meter
blobce59fc2d8de496ee6c12e4032949136a27ee3b62
1 #!/usr/bin/python
3 # Copyright 2004 Matt Mackall <mpm@selenic.com>
5 # inspired by perl Bloat-O-Meter (c) 1997 by Andi Kleen
7 # This software may be used and distributed according to the terms
8 # of the GNU General Public License, incorporated herein by reference.
10 import sys, os, re
12 if len(sys.argv) != 3:
13 sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
14 sys.exit(-1)
16 def getsizes(file):
17 sym = {}
18 for l in os.popen("nm --size-sort " + file).readlines():
19 size, type, name = l[:-1].split()
20 if type in "tTdDbB":
21 if "." in name: name = "static." + name.split(".")[0]
22 sym[name] = sym.get(name, 0) + int(size, 16)
23 return sym
25 old = getsizes(sys.argv[1])
26 new = getsizes(sys.argv[2])
27 grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
28 delta, common = [], {}
30 for a in old:
31 if a in new:
32 common[a] = 1
34 for name in old:
35 if name not in common:
36 remove += 1
37 down += old[name]
38 delta.append((-old[name], name))
40 for name in new:
41 if name not in common:
42 add += 1
43 up += new[name]
44 delta.append((new[name], name))
46 for name in common:
47 d = new.get(name, 0) - old.get(name, 0)
48 if d>0: grow, up = grow+1, up+d
49 if d<0: shrink, down = shrink+1, down-d
50 delta.append((d, name))
52 delta.sort()
53 delta.reverse()
55 print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
56 (add, remove, grow, shrink, up, -down, up-down)
57 print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
58 for d, n in delta:
59 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)