From: Aristeu Rozanski <aris@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Josh Triplett <josh@joshtriplett.org>
Subject: [PATCH] scripts/bloat-o-meter: include .rodata section comparison
Date: Mon, 12 Jan 2015 12:02:49 -0500 [thread overview]
Message-ID: <20150112170249.GC10329@redhat.com> (raw)
This patch adds section .rodata comparison in order to detect string
constant changes.
Cc: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 23e78dc..cee812a 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -26,40 +26,66 @@ def getsizes(file):
# statics and some other optimizations adds random .NUMBER
name = re.sub(r'\.[0-9]+', '', name)
sym[name] = sym.get(name, 0) + int(size, 16)
- return sym
-old = getsizes(sys.argv[1])
-new = getsizes(sys.argv[2])
-grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
-delta, common = [], {}
+ sections = {}
+ exp = re.compile('[\ ]*[0-9]+[\ ]+([^\ ]+)[\ ]+([0-9a-f]+).*')
+ wanted_sections = ['.rodata']
+ for l in os.popen("objdump -h -w " + file).readlines():
+ match = exp.match(l)
+ if not match:
+ continue
+ name = match.group(1)
+ if name not in wanted_sections:
+ continue
+ size = int(match.group(2), 16)
+ sections[name] = size
-for a in old:
- if a in new:
- common[a] = 1
+ return (sym, sections)
-for name in old:
- if name not in common:
- remove += 1
- down += old[name]
- delta.append((-old[name], name))
+def process_results(old, new):
+ grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
+ delta, common = [], {}
+ for a in old:
+ if a in new:
+ common[a] = 1
-for name in new:
- if name not in common:
- add += 1
- up += new[name]
- delta.append((new[name], name))
+ for name in old:
+ if name not in common:
+ remove += 1
+ down += old[name]
+ delta.append((-old[name], name))
-for name in common:
- d = new.get(name, 0) - old.get(name, 0)
- if d>0: grow, up = grow+1, up+d
- if d<0: shrink, down = shrink+1, down-d
- delta.append((d, name))
+ for name in new:
+ if name not in common:
+ add += 1
+ up += new[name]
+ delta.append((new[name], name))
-delta.sort()
-delta.reverse()
+ for name in common:
+ d = new.get(name, 0) - old.get(name, 0)
+ if d>0: grow, up = grow+1, up+d
+ if d<0: shrink, down = shrink+1, down-d
+ delta.append((d, name))
-print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
- (add, remove, grow, shrink, up, -down, up-down)
-print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
-for d, n in delta:
- if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)
+ delta.sort()
+ delta.reverse()
+
+ return (add, remove, up, down, grow, shrink, delta)
+
+def print_results(title, add, remove, up, down, grow, shrink, delta, old, new):
+ print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
+ (add, remove, grow, shrink, up, -down, up-down)
+ print "%-40s %7s %7s %+7s" % (title, "old", "new", "delta")
+ for d, n in delta:
+ if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)
+
+old, old_sections = getsizes(sys.argv[1])
+new, new_sections = getsizes(sys.argv[2])
+
+(add, remove, up, down, grow, shrink, delta) = process_results(old, new)
+print "Symbols changes"
+print_results("function", add, remove, up, down, grow, shrink, delta, old, new)
+
+(add, remove, up, down, grow, shrink, delta) = process_results(old_sections, new_sections)
+print "\nSection changes"
+print_results("section", add, remove, up, down, grow, shrink, delta, old_sections, new_sections)
reply other threads:[~2015-01-12 17:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150112170249.GC10329@redhat.com \
--to=aris@redhat.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.