MCPcopy Index your code
hub / github.com/pythonprofilers/memory_profiler / peak_action

Function peak_action

mprof.py:861–884  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

859 return filtered_memory
860
861def peak_action():
862 desc = """Prints the peak memory used in data file `file.dat` generated
863using `mprof run`. If no .dat file is given, it will take the most recent
864such 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
887def get_profiles(args):

Callers

nothing calls this directly

Calls 4

get_profilesFunction · 0.85
read_mprofile_fileFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected