Commit 3af06fd9 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

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@avx2Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3fb4afd9
...@@ -18,17 +18,18 @@ if len(sys.argv) != 3: ...@@ -18,17 +18,18 @@ if len(sys.argv) != 3:
def getsizes(file): def getsizes(file):
sym = {} sym = {}
for l in os.popen("nm --size-sort " + file).readlines(): with os.popen("nm --size-sort " + file) as f:
size, type, name = l[:-1].split() for line in f:
if type in "tTdDbBrR": size, type, name = line.split()
# strip generated symbols if type in "tTdDbBrR":
if name.startswith("__mod_"): continue # strip generated symbols
if name.startswith("SyS_"): continue if name.startswith("__mod_"): continue
if name.startswith("compat_SyS_"): continue if name.startswith("SyS_"): continue
if name == "linux_banner": continue if name.startswith("compat_SyS_"): continue
# statics and some other optimizations adds random .NUMBER if name == "linux_banner": continue
name = re.sub(r'\.[0-9]+', '', name) # statics and some other optimizations adds random .NUMBER
sym[name] = sym.get(name, 0) + int(size, 16) name = re.sub(r'\.[0-9]+', '', name)
sym[name] = sym.get(name, 0) + int(size, 16)
return sym return sym
old = getsizes(sys.argv[1]) old = getsizes(sys.argv[1])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment