| 1 |
|
| 2 |
|
| 3 |
""" |
| 4 |
Usage: reportstaticdata.py [-m1|-m2|-t] [OPTION]... FILENAME |
| 5 |
Print a report for the static data information contained in FILENAME |
| 6 |
|
| 7 |
The static data information is saved in the file staticdata.info when |
| 8 |
passing --dump_static_data_info to translate.py. |
| 9 |
|
| 10 |
Options: |
| 11 |
|
| 12 |
-m1 Print a report for each module, counting constants that are |
| 13 |
reacheable from more than one module multiple times (default) |
| 14 |
|
| 15 |
-m2 Print a report for each module, counting constants that are |
| 16 |
reacheable from more than one module only in the first module |
| 17 |
seen |
| 18 |
|
| 19 |
-t Print a global report for all the constants |
| 20 |
|
| 21 |
-h Print sizes in human readable formats (e.g., 1K 234M) |
| 22 |
|
| 23 |
-s Print only the total size for each module |
| 24 |
|
| 25 |
-u Print the list of graphs which belongs to unknown modules |
| 26 |
|
| 27 |
--help Show this help message |
| 28 |
""" |
| 29 |
|
| 30 |
import sys |
| 31 |
|
| 32 |
from rpython.translator.tool.staticsizereport import print_report |
| 33 |
|
| 34 |
def parse_options(argv): |
| 35 |
kwds = {} |
| 36 |
for arg in argv: |
| 37 |
if arg.startswith('-'): |
| 38 |
if arg == '-m1': |
| 39 |
assert 'kind' not in kwds |
| 40 |
kwds['kind'] = 'by_module_with_duplicates' |
| 41 |
elif arg == '-m2': |
| 42 |
assert 'kind' not in kwds |
| 43 |
kwds['kind'] = 'by_module_without_duplicates' |
| 44 |
elif arg == '-t': |
| 45 |
assert 'kind' not in kwds |
| 46 |
kwds['kind'] = 'by_type' |
| 47 |
elif arg == '-h': |
| 48 |
kwds['human_readable'] = True |
| 49 |
elif arg == '-s': |
| 50 |
kwds['summary'] = True |
| 51 |
elif arg == '-u': |
| 52 |
kwds['show_unknown_graphs'] = True |
| 53 |
elif arg == '--help': |
| 54 |
raise AssertionError |
| 55 |
else: |
| 56 |
assert 'filename' not in kwds |
| 57 |
kwds['filename'] = arg |
| 58 |
|
| 59 |
assert 'filename' in kwds |
| 60 |
return kwds |
| 61 |
|
| 62 |
|
| 63 |
def main(): |
| 64 |
try: |
| 65 |
kwds = parse_options(sys.argv[1:]) |
| 66 |
except AssertionError: |
| 67 |
print >> sys.stderr, __doc__ |
| 68 |
sys.exit(1) |
| 69 |
print_report(**kwds) |
| 70 |
|
| 71 |
if __name__ == '__main__': |
| 72 |
main() |