aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Mackall <mpm@selenic.com>2006-01-08 04:05:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:14:10 -0500
commitd960600df3ce3588571e2c1adf1f5f6d8ca9eb5a (patch)
tree2d920b912b33f16b5cf8099331fcf421c83ae64b
parente701e85b9f12af4dbe73b4299b541686ef6b1aa5 (diff)
[PATCH] tiny: Add bloat-o-meter to scripts
This is a rewrite of Andi Kleen's bloat-o-meter with sorting and reporting of gainers/decliners. Sample output: add/remove: 0/8 grow/shrink: 2/0 up/down: 88/-4424 (-4336) function old new delta __copy_to_user_ll 59 103 +44 __copy_from_user_ll 59 103 +44 fill_note 32 - -32 maydump 58 - -58 dump_seek 67 - -67 writenote 180 - -180 elf_dump_thread_status 274 - -274 fill_psinfo 308 - -308 fill_prstatus 466 - -466 elf_core_dump 3039 - -3039 The summary line says: no functions added, 8 removed two functions grew, none shrunk we gained 88 bytes and lost 4424 (or -4336 net) This work was sponsored in part by CE Linux Forum Signed-off-by: Matt Mackall <mpm@selenic.com> Cc: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--scripts/bloat-o-meter58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
new file mode 100644
index 000000000000..75f21d843c1d
--- /dev/null
+++ b/scripts/bloat-o-meter
@@ -0,0 +1,58 @@
1#!/usr/bin/python
2#
3# Copyright 2004 Matt Mackall <mpm@selenic.com>
4#
5# inspired by perl Bloat-O-Meter (c) 1997 by Andi Kleen
6#
7# This software may be used and distributed according to the terms
8# of the GNU General Public License, incorporated herein by reference.
9
10import sys, os, re
11
12if len(sys.argv) != 3:
13 sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
14 sys.exit(-1)
15
16def 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 sym[name] = int(size, 16)
22 return sym
23
24old = getsizes(sys.argv[1])
25new = getsizes(sys.argv[2])
26grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
27delta, common = [], {}
28
29for a in old:
30 if a in new:
31 common[a] = 1
32
33for name in old:
34 if name not in common:
35 remove += 1
36 down += old[name]
37 delta.append((-old[name], name))
38
39for name in new:
40 if name not in common:
41 add += 1
42 up += new[name]
43 delta.append((new[name], name))
44
45for name in common:
46 d = new.get(name, 0) - old.get(name, 0)
47 if d>0: grow, up = grow+1, up+d
48 if d<0: shrink, down = shrink+1, down-d
49 delta.append((d, name))
50
51delta.sort()
52delta.reverse()
53
54print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
55 (add, remove, grow, shrink, up, -down, up-down)
56print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
57for d, n in delta:
58 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)