summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2016-12-12 16:40:45 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 18:55:06 -0800
commit3af06fd96aae18561830745880ca6e289053edae (patch)
tree75e88233acc979470ecda89f88fe9cdc01ede83c
parent3fb4afd9a504c2386b8435028d43283216bf588e (diff)
downloadlinux-3af06fd96aae18561830745880ca6e289053edae.tar.bz2
scripts/bloat-o-meter: don't use readlines()
readlines() conses whole list before doing anything which is slower for big object files. Use per line iterator. Speed up is ~2% on "allyesconfig" type of kernel. $ perf stat -r 16 taskset -c 15 ./scripts/bloat-o-meter ../vmlinux-000 ../obj/vmlinux >/dev/null ... Before: 7.247708646 seconds time elapsed ( +- 0.28% ) After: 7.091202853 seconds time elapsed ( +- 0.15% ) Link: http://lkml.kernel.org/r/20161119004143.GA1200@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rwxr-xr-xscripts/bloat-o-meter23
1 files changed, 12 insertions, 11 deletions
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index d9ff038c1b28..378dfd7ff81d 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -18,17 +18,18 @@ if len(sys.argv) != 3:
def getsizes(file):
sym = {}
- for l in os.popen("nm --size-sort " + file).readlines():
- size, type, name = l[:-1].split()
- if type in "tTdDbBrR":
- # strip generated symbols
- if name.startswith("__mod_"): continue
- if name.startswith("SyS_"): continue
- if name.startswith("compat_SyS_"): continue
- if name == "linux_banner": continue
- # statics and some other optimizations adds random .NUMBER
- name = re.sub(r'\.[0-9]+', '', name)
- sym[name] = sym.get(name, 0) + int(size, 16)
+ with os.popen("nm --size-sort " + file) as f:
+ for line in f:
+ size, type, name = line.split()
+ if type in "tTdDbBrR":
+ # strip generated symbols
+ if name.startswith("__mod_"): continue
+ if name.startswith("SyS_"): continue
+ if name.startswith("compat_SyS_"): continue
+ if name == "linux_banner": continue
+ # 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])