utils/size-stats-compare: clarify meaning of variables in print_result
PATCH v2 1/2 utils/size-stats-compare: clarify meaning of variables in print_result
From: Thomas De Schampheleire <[email protected]>
print_result is juggling with entry[x][y] which is not very readable. While a better solution would be to use a class and reference named attributes, that would require some bigger changes in the script.
Instead, make a minimal improvement by assigning the entry[x][y] values to intermediate variables. Store them in a dict for easy usage from a format string.
---
v2: new patch
utils/size-stats-compare | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
utils/size-stats-compare +9 -2
@@ -77,9 +77,16 @@ def print_results(result, threshold): # list_result is a list of tuples: (name, (flag, size difference)) for entry in sorted(list_result, key=lambda entry: entry[1][1]): - if threshold is not None and abs(entry[1][1]) <= threshold: + + data = dict( + name=entry[0], + action=entry[1][0], + size=entry[1][1], + ) + + if threshold is not None and abs(data['size']) <= threshold: continue - print('%12s %7s %s' % (entry[1][1], entry[1][0], entry[0])) + print('{size:12d} {action:7s} {name}'.format(**data)) # main #########################################################################
Signature · 1 line
2.26.2
PATCH v2 2/2 utils/size-stats-compare: add package name in detail output
From: Thomas De Schampheleire <[email protected]>
size-stats-compare gives an overview of the size increase/decrease between two cases, based on packages-file-list.txt. The 'detail' mode gives info per file, otherwise per package.
But sometimes, you want the detailed per-file info, but only for a specific package. Since the detailed output no longer lists the package name, you cannot simply grep for it. A workaround was to filter the input packages-file-list.txt's first, and then pass these filtered versions to size-stats-compare.
Make this easier by adding the package name next to the filename in detailed output. This allows grep'ing normally.
For example:
$ utils/size-stats-compare orig new -t 100 -d | grep ebtables
-67712 removed ebtables lib/ebtables/libebtc.so
-66764 removed ebtables lib/ebtables/libebt_nat.so
-66752 removed ebtables sbin/ebtables
-66704 removed ebtables lib/ebtables/libebt_arp.so
-66700 removed ebtables lib/ebtables/libebt_stp.so
-66700 removed ebtables lib/ebtables/libebt_among.so
-66684 removed ebtables lib/ebtables/libebt_ip.so
-66676 removed ebtables lib/ebtables/libebt_limit.so
-66656 removed ebtables lib/ebtables/libebt_log.so
-66648 removed ebtables lib/ebtables/libebt_mark.so
-66636 removed ebtables lib/ebtables/libebt_pkttype.so
-66604 removed ebtables lib/ebtables/libebt_vlan.so
-66588 removed ebtables lib/ebtables/libebt_ulog.so
-66588 removed ebtables lib/ebtables/libebt_nflog.so
-66584 removed ebtables lib/ebtables/libebt_arpreply.so
-66544 removed ebtables lib/ebtables/libebt_ip6.so
-66540 removed ebtables lib/ebtables/libebt_802_3.so
-66536 removed ebtables lib/ebtables/libebt_standard.so
-66524 removed ebtables lib/ebtables/libebt_mark_m.so
-66524 removed ebtables lib/ebtables/libebt_redirect.so
-66452 removed ebtables lib/ebtables/libebtable_filter.so
-66452 removed ebtables lib/ebtables/libebtable_broute.so
-66452 removed ebtables lib/ebtables/libebtable_nat.so
45 ebtables etc/ethertypes
66752 added ebtables usr/sbin/ebtablesd
66752 added ebtables usr/sbin/ebtables-legacy
66752 added ebtables usr/sbin/ebtablesu
200840 added ebtables usr/lib/libebtc.so.0.0.0---
v2: move package name in front of filename (comment by Yann)
utils/size-stats-compare | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
utils/size-stats-compare +15 -7
@@ -40,9 +40,9 @@ def read_file_size_csv(inputf, detail=None): for row in reader: if detail: - sizes[row[0]] = int(row[2]) + sizes[(row[0], row[1])] = int(row[2]) else: - sizes[row[1]] = int(row[3]) + sizes[(None, row[1])] = int(row[3]) return sizes
@@ -73,20 +73,28 @@ def print_results(result, threshold): from six import iteritems list_result = list(iteritems(result)) - # result is a dictionary: name -> (flag, size difference) - # list_result is a list of tuples: (name, (flag, size difference)) + # result is a dictionary: (filename, pkgname) -> (flag, size difference) + # list_result is a list of tuples: ((filename, pkgname), (flag, size difference)) + # filename may be None if no detail is requested. + + maxpkgname=max(len(pkgname) for filename, pkgname in result) for entry in sorted(list_result, key=lambda entry: entry[1][1]): data = dict( - name=entry[0], + filename=entry[0][0], + pkgname=entry[0][1], action=entry[1][0], size=entry[1][1], + maxpkgname=maxpkgname, ) if threshold is not None and abs(data['size']) <= threshold: continue - print('{size:12d} {action:7s} {name}'.format(**data)) + if data['filename']: + print('{size:12d} {action:7s} {pkgname:{maxpkgname}s} {filename}'.format(**data)) + else: + print('{size:12d} {action:7s} {pkgname}'.format(**data)) # main #########################################################################
@@ -133,5 +141,5 @@ print('Size difference per %s (bytes), threshold = %s' % (keyword, args.threshol print(80*'-') print_results(delta, args.threshold) print(80*'-') -print_results({'TOTAL': ('', sum(new_sizes.values()) - sum(old_sizes.values()))}, +print_results({(None, 'TOTAL'): ('', sum(new_sizes.values()) - sum(old_sizes.values()))}, threshold=None)
Signature · 1 line
2.26.2
Quoted 11 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
print_resultis juggling with entry[x][y] which is not very readable. While a better solution would be to use a class and reference named attributes, that would require some bigger changes in the script.Instead, make a minimal improvement by assigning the entry[x][y] values to intermediate variables. Store them in a dict for easy usage from a format string.
Signed-off-by Thomas De Schampheleire <[email protected]>
Series applied to master, thanks.
It's a bit silly that this has to take a year, but it is what it is...
Regards,
Arnout
Quoted 19 lines
---
v2: new patchutils/size-stats-compare | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)utils/size-stats-compare +4
-1@@ -77,9 +77,16 @@ def print_results(result, threshold): # list_result is a list of tuples: (name, (flag, size difference)) for entry in sorted(list_result, key=lambda entry: entry[1][1]): - if threshold is not None and abs(entry[1][1]) <= threshold: + + data = dict( + name=entry[0], + action=entry[1][0],
utils/size-stats-compare def print_results(result, threshold): · line 92
Quoted 10 lines
utils/size-stats-compare +5
-1+ size=entry[1][1], + ) + + if threshold is not None and abs(data['size']) <= threshold: continue - print('%12s %7s %s' % (entry[1][1], entry[1][0], entry[0])) + print('{size:12d} {action:7s} {name}'.format(**data)) # main #########################################################################
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 14 lines · Arnout Vandecappelle
Quoted 10 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
print_resultis juggling with entry[x][y] which is not very readable. While a better solution would be to use a class and reference named attributes, that would require some bigger changes in the script.Instead, make a minimal improvement by assigning the entry[x][y] values to intermediate variables. Store them in a dict for easy usage from a format string.
Quoted 5 lines
Quoted 1 line
Signed-off-by Thomas De Schampheleire <[email protected]>Series applied to master, thanks.
It's a bit silly that this has to take a year, but it is what it is...
No worries, thanks in any case!
/Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot