aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-05-07 19:26:53 +0000
committerRob Landley <rob@landley.net>2006-05-07 19:26:53 +0000
commitf8a808426745ee5f4e5cc76ff1fb9c484c315195 (patch)
tree98685847c9ee70e5997466e29db22f8d46b30e36
parent9fb272a222c8c25dbd99d7c186f668516d6b3ebe (diff)
downloadbusybox-w32-f8a808426745ee5f4e5cc76ff1fb9c484c315195.tar.gz
busybox-w32-f8a808426745ee5f4e5cc76ff1fb9c484c315195.tar.bz2
busybox-w32-f8a808426745ee5f4e5cc76ff1fb9c484c315195.zip
Add "make bloatcheck" to run Matt Mackall's bloat-o-meter. Copy an old
busybox_unstripped to busybox_old, build a new version, and "make bloatcheck" to see a detailed breakdown of the size difference.
-rw-r--r--Makefile5
-rwxr-xr-xscripts/bloat-o-meter60
2 files changed, 65 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 974048fb9..a16a98c64 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,8 @@ help:
132 @echo ' uninstall' 132 @echo ' uninstall'
133 @echo 133 @echo
134 @echo 'Development:' 134 @echo 'Development:'
135 @echo ' bloatcheck - show size difference between busybox_unstripped'
136 @echo ' and busybox_old
135 @echo ' check - run the test suite for all applets' 137 @echo ' check - run the test suite for all applets'
136 @echo ' checkhelp - check for missing help-entries in Config.in' 138 @echo ' checkhelp - check for missing help-entries in Config.in'
137 @echo ' randconfig - generate a random configuration' 139 @echo ' randconfig - generate a random configuration'
@@ -358,6 +360,9 @@ checkhelp:
358.PHONY: sizes 360.PHONY: sizes
359sizes: busybox_unstripped 361sizes: busybox_unstripped
360 $(NM) --size-sort $(<) 362 $(NM) --size-sort $(<)
363.PHONY: bloatcheck
364bloatcheck: busybox_old busybox_unstripped
365 @scripts/bloat-o-meter busybox_old busybox_unstripped
361 366
362.PHONY: objsizes 367.PHONY: objsizes
363objsizes: busybox_unstripped 368objsizes: busybox_unstripped
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
new file mode 100755
index 000000000..af42f8402
--- /dev/null
+++ b/scripts/bloat-o-meter
@@ -0,0 +1,60 @@
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 if name.find(".") != -1: name = "static." + name.split(".")[0]
22 if name in sym: sym[name] += int(size, 16)
23 else :sym[name] = int(size, 16)
24 return sym
25
26old = getsizes(sys.argv[1])
27new = getsizes(sys.argv[2])
28grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
29delta, common = [], {}
30
31for a in old:
32 if a in new:
33 common[a] = 1
34
35for name in old:
36 if name not in common:
37 remove += 1
38 down += old[name]
39 delta.append((-old[name], name))
40
41for name in new:
42 if name not in common:
43 add += 1
44 up += new[name]
45 delta.append((new[name], name))
46
47for name in common:
48 d = new.get(name, 0) - old.get(name, 0)
49 if d>0: grow, up = grow+1, up+d
50 if d<0: shrink, down = shrink+1, down-d
51 delta.append((d, name))
52
53delta.sort()
54delta.reverse()
55
56print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
57 (add, remove, grow, shrink, up, -down, up-down)
58print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
59for d, n in delta:
60 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)