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

Function function_labels

mprof.py:728–752  ·  view source on GitHub ↗
(dotted_function_names)

Source from the content-addressed store, hash-verified

726
727
728def function_labels(dotted_function_names):
729 state = {}
730
731 def set_state_for(function_names, level):
732 for fn in function_names:
733 label = ".".join(fn.split(".")[-level:])
734 label_state = state.setdefault(label, {"functions": [],
735 "level": level})
736 label_state["functions"].append(fn)
737
738 set_state_for(dotted_function_names, 1)
739
740 while True:
741 ambiguous_labels = [label for label in state if len(state[label]["functions"]) > 1]
742 for ambiguous_label in ambiguous_labels:
743 function_names = state[ambiguous_label]["functions"]
744 new_level = state[ambiguous_label]["level"] + 1
745 del state[ambiguous_label]
746 set_state_for(function_names, new_level)
747 if len(ambiguous_labels) == 0:
748 break
749
750 fn_to_label = dict((label_state["functions"][0] , label) for label, label_state in state.items())
751
752 return fn_to_label
753
754
755def plot_action():

Callers 2

plot_fileFunction · 0.85
flame_plotterFunction · 0.85

Calls 2

set_state_forFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected