()
| 859 | return filtered_memory |
| 860 | |
| 861 | def peak_action(): |
| 862 | desc = """Prints the peak memory used in data file `file.dat` generated |
| 863 | using `mprof run`. If no .dat file is given, it will take the most recent |
| 864 | such file in the current directory.""" |
| 865 | parser = ArgumentParser(usage="mprof peak [options] [file.dat]", description=desc) |
| 866 | parser.add_argument("profiles", nargs="*", |
| 867 | help="profiles made by mprof run") |
| 868 | parser.add_argument("--func", dest="func", default=None, |
| 869 | help="""Show the peak for this function. Does not support child processes.""") |
| 870 | args = parser.parse_args() |
| 871 | filenames = get_profiles(args) |
| 872 | |
| 873 | for filename in filenames: |
| 874 | prof = read_mprofile_file(filename) |
| 875 | try: |
| 876 | mem_usage = filter_mprofile_mem_usage_by_function(prof, args.func) |
| 877 | except ValueError: |
| 878 | print("{}\tNaN MiB".format(prof["filename"])) |
| 879 | continue |
| 880 | |
| 881 | print("{}\t{:.3f} MiB".format(prof["filename"], max(mem_usage))) |
| 882 | for child, values in prof["children"].items(): |
| 883 | child_peak = max([ mem_ts[0] for mem_ts in values ]) |
| 884 | print(" Child {}\t\t\t{:.3f} MiB".format(child, child_peak)) |
| 885 | |
| 886 | |
| 887 | def get_profiles(args): |
nothing calls this directly
no test coverage detected