History

perf scripts python: exported-sql-viewer.py: Add ability for Call tree to open at a specified task and time

Add ability for Call tree to open at a specified task and time.

Adrian Hunter committed 7 years ago

Commit e69d5df1 parent da4264f1 file · +43 −1Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/exported-sql-viewer.py+43−1
@@ -1094,7 +1094,7 @@ class CallGraphWindow(TreeWindowBase): · 1093 unmodified lines
10941094
10951095 class CallTreeWindow(TreeWindowBase):
10961096
1097− def __init__(self, glb, parent=None):
1097+ def __init__(self, glb, parent=None, thread_at_time=None):
10981098 super(CallTreeWindow, self).__init__(parent)
10991099
11001100 self.model = LookupCreateModel("Call Tree", lambda x=glb: CallTreeModel(x))
@@ -1112,6 +1112,48 @@ class CallTreeWindow(TreeWindowBase): · 11 unmodified lines
11121112
11131113 AddSubWindow(glb.mainwindow.mdi_area, self, "Call Tree")
11141114
1115+ if thread_at_time:
1116+ self.DisplayThreadAtTime(*thread_at_time)
1117+
1118+ def DisplayThreadAtTime(self, comm_id, thread_id, time):
1119+ parent = QModelIndex()
1120+ for dbid in (comm_id, thread_id):
1121+ found = False
1122+ n = self.model.rowCount(parent)
1123+ for row in xrange(n):
1124+ child = self.model.index(row, 0, parent)
1125+ if child.internalPointer().dbid == dbid:
1126+ found = True
1127+ self.view.setCurrentIndex(child)
1128+ parent = child
1129+ break
1130+ if not found:
1131+ return
1132+ found = False
1133+ while True:
1134+ n = self.model.rowCount(parent)
1135+ if not n:
1136+ return
1137+ last_child = None
1138+ for row in xrange(n):
1139+ child = self.model.index(row, 0, parent)
1140+ child_call_time = child.internalPointer().call_time
1141+ if child_call_time < time:
1142+ last_child = child
1143+ elif child_call_time == time:
1144+ self.view.setCurrentIndex(child)
1145+ return
1146+ elif child_call_time > time:
1147+ break
1148+ if not last_child:
1149+ if not found:
1150+ child = self.model.index(0, 0, parent)
1151+ self.view.setCurrentIndex(child)
1152+ return
1153+ found = True
1154+ self.view.setCurrentIndex(last_child)
1155+ parent = last_child
1156+
11151157 # Child data item finder
11161158
11171159 class ChildDataItemFinder():