Re: [PATCH] update kernel's scripts/bloat-o-meter from busybox

From: Mike Frysinger
Date: Mon Jun 01 2009 - 16:39:21 EST


On Mon, Jun 1, 2009 at 15:48, Matt Mackall wrote:
> On Mon, 2009-06-01 at 15:26 -0400, Robin Getz wrote:
>> --- scripts/bloat-o-meter   (revision 6437)
>> +++ scripts/bloat-o-meter   (working copy)
>> @@ -9,18 +9,37 @@
>>
>> Âimport sys, os, re
>>
>> -if len(sys.argv) != 3:
>> +def usage():
>> Â Â Âsys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
>> Â Â Âsys.exit(-1)
>>
>> +if len(sys.argv) < 3:
>> + Â Âusage()
>> +
>> +for f in sys.argv[1], sys.argv[2]:
>
> in sys.argv[1:3]: Âis a bit more standard
>
> But this test should instead happen inside getsizes, no loop needed.
>
>> + Â Âif not os.path.exists(f):
>> + Â Â Â Âsys.stderr.write("Error: file '%s' does not exist\n" % f)
>> + Â Â Â Âusage()
>> +
>> +nm_args = " ".join([x for x in sys.argv[3:]])
>
> nm_args = " ".join(sys.argv[3:])

ive made the argv changes in busybox upstream

>> Âdef getsizes(file):
>> Â Â Âsym = {}
>> - Â Âfor l in os.popen("nm --size-sort " + file).readlines():
>> - Â Â Â Âsize, type, name = l[:-1].split()
>> - Â Â Â Âif type in "tTdDbB":
>> + Â Âfor l in os.popen("nm --size-sort %s %s" % (nm_args, file)).readlines():
>> + Â Â l = l.strip()
>> + Â Â # Skip empty lines
>> + Â Â Â Âif not len(l): continue
>
> (seems to be some whitespace damage? there should be no tabs in this
> source)

fixed the whitespace damage (all spaces)

>> Âold = getsizes(sys.argv[1])
>> @@ -53,8 +72,10 @@
>> Âdelta.sort()
>> Âdelta.reverse()
>>
>> -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")
>> +print "%-48s %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)
>> + Â Âif d: print "%-48s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)
>> +print "-"*78
>> +total="(add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s)%%sTotal: %s
>> bytes"\
>> + Â Â% (add, remove, grow, shrink, up, -down, up-down)
>> +print total % (" "*(80-len(total)))
>
> Not terribly excited about this last bit, which is going out of its way
> to right-align the total? Who cares about that?

it makes things a lot easier to read, especially in commit scripts

as for the rest of your comments, Denis or Rob can tackle those
-mike
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/