Add basic notebook for profiling analysis

This commit is contained in:
Christophe Bedard 2019-08-06 14:38:34 +02:00
parent 785cb5af72
commit 6724a41ab8
2 changed files with 657 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -68,22 +68,26 @@ class ProfileDataModelUtil():
tree[parent].add(name) tree[parent].add(name)
return dict(tree) return dict(tree)
def get_stats(self, tid: int): def get_function_duration_data(self, tid: int) -> List[Dict[str, Union[int, str, DataFrame]]]:
"""Get profiling statistics.""" """Get duration data for each function."""
tid_df = self.with_tid(tid) tid_df = self.with_tid(tid)
depth_names = tid_df[['depth', 'function_name', 'parent_name']].drop_duplicates() depth_names = tid_df[['depth', 'function_name', 'parent_name']].drop_duplicates()
print('depth_names') functions_data = []
print(depth_names.to_string())
for _, row in depth_names.iterrows(): for _, row in depth_names.iterrows():
depth = row['depth'] depth = row['depth']
name = row['function_name'] name = row['function_name']
parent = row['parent_name'] parent = row['parent_name']
desc = tid_df.loc[ data = tid_df.loc[
(tid_df['depth'] == depth) & (tid_df['depth'] == depth) &
(tid_df['function_name'] == name) (tid_df['function_name'] == name)
]['duration'].astype(int).describe() ][['start_timestamp', 'duration', 'actual_duration']]
print(depth, name, parent) functions_data.append({
print(desc) 'depth': depth,
'function_name': name,
'parent_name': parent,
'data': data,
})
return functions_data
class CpuTimeDataModelUtil(): class CpuTimeDataModelUtil():
@ -230,6 +234,19 @@ class RosDataModelUtil():
assert len(node_row.index) <= 1, 'more than 1 node found' assert len(node_row.index) <= 1, 'more than 1 node found'
return node_row.iloc[0]['tid'] if not node_row.empty else None return node_row.iloc[0]['tid'] if not node_row.empty else None
def get_node_names_from_tid(
self, tid: str
) -> Union[List[str], None]:
"""
Get the list of node names corresponding to a tid.
:param tid: the tid
:return: the list of node names, or `None` if not found
"""
return self.data.nodes[
self.data.nodes['tid'] == tid
]['name'].tolist()
def get_callback_owner_info( def get_callback_owner_info(
self, callback_obj: int self, callback_obj: int
) -> Union[str, None]: ) -> Union[str, None]: