MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / index_of

Method index_of

tensorflow/python/profiler/pprof_profiler.py:118–141  ·  view source on GitHub ↗

Returns index of the function, adding the function if needed. Args: file_path: (string) Path to file where the function is defined. function_name: (string) Function name. function_start_line: (integer) Start line number of function definition. Returns: Function inde

(self, file_path, function_name, function_start_line)

Source from the content-addressed store, hash-verified

116 self._function_key_to_function = {}
117
118 def index_of(self, file_path, function_name, function_start_line):
119 """Returns index of the function, adding the function if needed.
120
121 Args:
122 file_path: (string) Path to file where the function is defined.
123 function_name: (string) Function name.
124 function_start_line: (integer) Start line number of function definition.
125
126 Returns:
127 Function index.
128 """
129 function_key = (file_path, function_name, function_start_line)
130 if function_key in self._function_key_to_function:
131 return self._function_key_to_function[function_key].id
132 else:
133 # Function indexes should start from 1
134 function_index = len(self._function_key_to_function) + 1
135 function = profile_pb2.Function()
136 function.id = function_index
137 function.name = self._string_table.index_of(function_name)
138 function.filename = self._string_table.index_of(file_path)
139 function.start_line = function_start_line
140 self._function_key_to_function[function_key] = function
141 return function_index
142
143 def function_protos(self):
144 """Returns list of `profile_pb2.Function` protos."""

Callers 3

index_ofMethod · 0.45
addMethod · 0.45
_get_pprof_protoMethod · 0.45

Calls 1

FunctionMethod · 0.45

Tested by

no test coverage detected