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

Function show_results

memory_profiler.py:853–883  ·  view source on GitHub ↗
(prof, stream=None, precision=1)

Source from the content-addressed store, hash-verified

851
852
853def show_results(prof, stream=None, precision=1):
854 if stream is None:
855 stream = sys.stdout
856 template = '{0:>6} {1:>12} {2:>12} {3:>10} {4:<}'
857
858 for (filename, lines) in prof.code_map.items():
859 header = template.format('Line #', 'Mem usage', 'Increment', 'Occurrences',
860 'Line Contents')
861
862 stream.write(u'Filename: ' + filename + '\n\n')
863 stream.write(header + u'\n')
864 stream.write(u'=' * len(header) + '\n')
865
866 all_lines = linecache.getlines(filename)
867
868 float_format = u'{0}.{1}f'.format(precision + 4, precision)
869 template_mem = u'{0:' + float_format + '} MiB'
870 for (lineno, mem) in lines:
871 if mem:
872 inc = mem[0]
873 total_mem = mem[1]
874 total_mem = template_mem.format(total_mem)
875 occurrences = mem[2]
876 inc = template_mem.format(inc)
877 else:
878 total_mem = u''
879 inc = u''
880 occurrences = u''
881 tmp = template.format(lineno, total_mem, inc, occurrences, all_lines[lineno - 1])
882 stream.write(tmp)
883 stream.write(u'\n\n')
884
885
886def _func_exec(stmt, ns):

Callers 6

mprunMethod · 0.90
memory_profiler.pyFile · 0.90
test_loop_countMethod · 0.90
test_normal_incrMethod · 0.90
test_loop_incrMethod · 0.90
test_decrMethod · 0.90

Calls 2

itemsMethod · 0.80
writeMethod · 0.80

Tested by 4

test_loop_countMethod · 0.72
test_normal_incrMethod · 0.72
test_loop_incrMethod · 0.72
test_decrMethod · 0.72