History

perf scripts python: exported-sql-viewer.py: Add CallGraphModelParams

Add a parameter to call graph and call tree, to determine whether IPC information is available.

Adrian Hunter committed 7 years ago

Commit 4a0979d1 parent 530e22f1 file · +41 −32Browse 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+41−32
@@ -200,9 +200,10 @@ class Thread(QThread): · 199 unmodified lines
200200
201201 class TreeModel(QAbstractItemModel):
202202
203− def __init__(self, glb, parent=None):
203+ def __init__(self, glb, params, parent=None):
204204 super(TreeModel, self).__init__(parent)
205205 self.glb = glb
206+ self.params = params
206207 self.root = self.GetRoot()
207208 self.last_row_read = 0
208209
@@ -463,8 +464,9 @@ class FindBar(): · 254 unmodified lines
463464
464465 class CallGraphLevelItemBase(object):
465466
466− def __init__(self, glb, row, parent_item):
467+ def __init__(self, glb, params, row, parent_item):
467468 self.glb = glb
469+ self.params = params
468470 self.row = row
469471 self.parent_item = parent_item
470472 self.query_done = False;
@@ -503,8 +505,8 @@ class CallGraphLevelItemBase(object): · 32 unmodified lines
503505
504506 class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase):
505507
506− def __init__(self, glb, row, comm_id, thread_id, call_path_id, time, branch_count, parent_item):
507− super(CallGraphLevelTwoPlusItemBase, self).__init__(glb, row, parent_item)
508+ def __init__(self, glb, params, row, comm_id, thread_id, call_path_id, time, branch_count, parent_item):
509+ super(CallGraphLevelTwoPlusItemBase, self).__init__(glb, params, row, parent_item)
508510 self.comm_id = comm_id
509511 self.thread_id = thread_id
510512 self.call_path_id = call_path_id
@@ -525,7 +527,7 @@ class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): · 14 unmodified lines
525527 " GROUP BY call_path_id, name, short_name"
526528 " ORDER BY call_path_id")
527529 while query.next():
528− child_item = CallGraphLevelThreeItem(self.glb, self.child_count, self.comm_id, self.thread_id, query.value(0), query.value(1), query.value(2), query.value(3), int(query.value(4)), int(query.value(5)), self)
530+ child_item = CallGraphLevelThreeItem(self.glb, self.params, self.child_count, self.comm_id, self.thread_id, query.value(0), query.value(1), query.value(2), query.value(3), int(query.value(4)), int(query.value(5)), self)
529531 self.child_items.append(child_item)
530532 self.child_count += 1
531533
@@ -533,8 +535,8 @@ class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): · 1 unmodified line
533535
534536 class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase):
535537
536− def __init__(self, glb, row, comm_id, thread_id, call_path_id, name, dso, count, time, branch_count, parent_item):
537− super(CallGraphLevelThreeItem, self).__init__(glb, row, comm_id, thread_id, call_path_id, time, branch_count, parent_item)
538+ def __init__(self, glb, params, row, comm_id, thread_id, call_path_id, name, dso, count, time, branch_count, parent_item):
539+ super(CallGraphLevelThreeItem, self).__init__(glb, params, row, comm_id, thread_id, call_path_id, time, branch_count, parent_item)
538540 dso = dsoname(dso)
539541 self.data = [ name, dso, str(count), str(time), PercentToOneDP(time, parent_item.time), str(branch_count), PercentToOneDP(branch_count, parent_item.branch_count) ]
540542 self.dbid = call_path_id
@@ -543,8 +545,8 @@ class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase): · 2 unmodified lines
543545
544546 class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase):
545547
546− def __init__(self, glb, row, comm_id, thread_id, pid, tid, parent_item):
547− super(CallGraphLevelTwoItem, self).__init__(glb, row, comm_id, thread_id, 1, 0, 0, parent_item)
548+ def __init__(self, glb, params, row, comm_id, thread_id, pid, tid, parent_item):
549+ super(CallGraphLevelTwoItem, self).__init__(glb, params, row, comm_id, thread_id, 1, 0, 0, parent_item)
548550 self.data = [str(pid) + ":" + str(tid), "", "", "", "", "", ""]
549551 self.dbid = thread_id
550552
@@ -561,8 +563,8 @@ class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase): · 10 unmodified lines
561563
562564 class CallGraphLevelOneItem(CallGraphLevelItemBase):
563565
564− def __init__(self, glb, row, comm_id, comm, parent_item):
565− super(CallGraphLevelOneItem, self).__init__(glb, row, parent_item)
566+ def __init__(self, glb, params, row, comm_id, comm, parent_item):
567+ super(CallGraphLevelOneItem, self).__init__(glb, params, row, parent_item)
566568 self.data = [comm, "", "", "", "", "", ""]
567569 self.dbid = comm_id
568570
@@ -574,7 +576,7 @@ class CallGraphLevelOneItem(CallGraphLevelItemBase): · 5 unmodified lines
574576 " INNER JOIN threads ON thread_id = threads.id"
575577 " WHERE comm_id = " + str(self.dbid))
576578 while query.next():
577− child_item = CallGraphLevelTwoItem(self.glb, self.child_count, self.dbid, query.value(0), query.value(1), query.value(2), self)
579+ child_item = CallGraphLevelTwoItem(self.glb, self.params, self.child_count, self.dbid, query.value(0), query.value(1), query.value(2), self)
578580 self.child_items.append(child_item)
579581 self.child_count += 1
580582
@@ -582,8 +584,8 @@ class CallGraphLevelOneItem(CallGraphLevelItemBase): · 1 unmodified line
582584
583585 class CallGraphRootItem(CallGraphLevelItemBase):
584586
585− def __init__(self, glb):
586− super(CallGraphRootItem, self).__init__(glb, 0, None)
587+ def __init__(self, glb, params):
588+ super(CallGraphRootItem, self).__init__(glb, params, 0, None)
587589 self.dbid = 0
588590 self.query_done = True;
589591 query = QSqlQuery(glb.db)
@@ -591,16 +593,23 @@ class CallGraphRootItem(CallGraphLevelItemBase): · 1 unmodified line
591593 while query.next():
592594 if not query.value(0):
593595 continue
594− child_item = CallGraphLevelOneItem(glb, self.child_count, query.value(0), query.value(1), self)
596+ child_item = CallGraphLevelOneItem(glb, params, self.child_count, query.value(0), query.value(1), self)
595597 self.child_items.append(child_item)
596598 self.child_count += 1
597599
600+# Call graph model parameters
601+
602+class CallGraphModelParams():
603+
604+ def __init__(self, glb, parent=None):
605+ self.have_ipc = IsSelectable(glb.db, "calls", columns = "insn_count, cyc_count")
606+
598607 # Context-sensitive call graph data model base
599608
600609 class CallGraphModelBase(TreeModel):
601610
602611 def __init__(self, glb, parent=None):
603− super(CallGraphModelBase, self).__init__(glb, parent)
612+ super(CallGraphModelBase, self).__init__(glb, CallGraphModelParams(glb), parent)
604613
605614 def FindSelect(self, value, pattern, query):
606615 if pattern:
@@ -682,7 +691,7 @@ class CallGraphModel(CallGraphModelBase): · 75 unmodified lines
682691 super(CallGraphModel, self).__init__(glb, parent)
683692
684693 def GetRoot(self):
685− return CallGraphRootItem(self.glb)
694+ return CallGraphRootItem(self.glb, self.params)
686695
687696 def columnCount(self, parent=None):
688697 return 7
@@ -729,8 +738,8 @@ class CallGraphModel(CallGraphModelBase): · 40 unmodified lines
729738
730739 class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase):
731740
732− def __init__(self, glb, row, comm_id, thread_id, calls_id, time, branch_count, parent_item):
733− super(CallTreeLevelTwoPlusItemBase, self).__init__(glb, row, parent_item)
741+ def __init__(self, glb, params, row, comm_id, thread_id, calls_id, time, branch_count, parent_item):
742+ super(CallTreeLevelTwoPlusItemBase, self).__init__(glb, params, row, parent_item)
734743 self.comm_id = comm_id
735744 self.thread_id = thread_id
736745 self.calls_id = calls_id
@@ -752,7 +761,7 @@ class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): · 15 unmodified lines
752761 " WHERE calls.parent_id = " + str(self.calls_id) + comm_thread +
753762 " ORDER BY call_time, calls.id")
754763 while query.next():
755− child_item = CallTreeLevelThreeItem(self.glb, self.child_count, self.comm_id, self.thread_id, query.value(0), query.value(1), query.value(2), query.value(3), int(query.value(4)), int(query.value(5)), self)
764+ child_item = CallTreeLevelThreeItem(self.glb, self.params, self.child_count, self.comm_id, self.thread_id, query.value(0), query.value(1), query.value(2), query.value(3), int(query.value(4)), int(query.value(5)), self)
756765 self.child_items.append(child_item)
757766 self.child_count += 1
758767
@@ -760,8 +769,8 @@ class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): · 1 unmodified line
760769
761770 class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase):
762771
763− def __init__(self, glb, row, comm_id, thread_id, calls_id, name, dso, count, time, branch_count, parent_item):
764− super(CallTreeLevelThreeItem, self).__init__(glb, row, comm_id, thread_id, calls_id, time, branch_count, parent_item)
772+ def __init__(self, glb, params, row, comm_id, thread_id, calls_id, name, dso, count, time, branch_count, parent_item):
773+ super(CallTreeLevelThreeItem, self).__init__(glb, params, row, comm_id, thread_id, calls_id, time, branch_count, parent_item)
765774 dso = dsoname(dso)
766775 self.data = [ name, dso, str(count), str(time), PercentToOneDP(time, parent_item.time), str(branch_count), PercentToOneDP(branch_count, parent_item.branch_count) ]
767776 self.dbid = calls_id
@@ -770,8 +779,8 @@ class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase): · 2 unmodified lines
770779
771780 class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase):
772781
773− def __init__(self, glb, row, comm_id, thread_id, pid, tid, parent_item):
774− super(CallTreeLevelTwoItem, self).__init__(glb, row, comm_id, thread_id, 0, 0, 0, parent_item)
782+ def __init__(self, glb, params, row, comm_id, thread_id, pid, tid, parent_item):
783+ super(CallTreeLevelTwoItem, self).__init__(glb, params, row, comm_id, thread_id, 0, 0, 0, parent_item)
775784 self.data = [str(pid) + ":" + str(tid), "", "", "", "", "", ""]
776785 self.dbid = thread_id
777786
@@ -788,8 +797,8 @@ class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase): · 10 unmodified lines
788797
789798 class CallTreeLevelOneItem(CallGraphLevelItemBase):
790799
791− def __init__(self, glb, row, comm_id, comm, parent_item):
792− super(CallTreeLevelOneItem, self).__init__(glb, row, parent_item)
800+ def __init__(self, glb, params, row, comm_id, comm, parent_item):
801+ super(CallTreeLevelOneItem, self).__init__(glb, params, row, parent_item)
793802 self.data = [comm, "", "", "", "", "", ""]
794803 self.dbid = comm_id
795804
@@ -801,7 +810,7 @@ class CallTreeLevelOneItem(CallGraphLevelItemBase): · 5 unmodified lines
801810 " INNER JOIN threads ON thread_id = threads.id"
802811 " WHERE comm_id = " + str(self.dbid))
803812 while query.next():
804− child_item = CallTreeLevelTwoItem(self.glb, self.child_count, self.dbid, query.value(0), query.value(1), query.value(2), self)
813+ child_item = CallTreeLevelTwoItem(self.glb, self.params, self.child_count, self.dbid, query.value(0), query.value(1), query.value(2), self)
805814 self.child_items.append(child_item)
806815 self.child_count += 1
807816
@@ -809,8 +818,8 @@ class CallTreeLevelOneItem(CallGraphLevelItemBase): · 1 unmodified line
809818
810819 class CallTreeRootItem(CallGraphLevelItemBase):
811820
812− def __init__(self, glb):
813− super(CallTreeRootItem, self).__init__(glb, 0, None)
821+ def __init__(self, glb, params):
822+ super(CallTreeRootItem, self).__init__(glb, params, 0, None)
814823 self.dbid = 0
815824 self.query_done = True;
816825 query = QSqlQuery(glb.db)
@@ -818,7 +827,7 @@ class CallTreeRootItem(CallGraphLevelItemBase): · 1 unmodified line
818827 while query.next():
819828 if not query.value(0):
820829 continue
821− child_item = CallTreeLevelOneItem(glb, self.child_count, query.value(0), query.value(1), self)
830+ child_item = CallTreeLevelOneItem(glb, params, self.child_count, query.value(0), query.value(1), self)
822831 self.child_items.append(child_item)
823832 self.child_count += 1
824833
@@ -830,7 +839,7 @@ class CallTreeModel(CallGraphModelBase): · 5 unmodified lines
830839 super(CallTreeModel, self).__init__(glb, parent)
831840
832841 def GetRoot(self):
833− return CallTreeRootItem(self.glb)
842+ return CallTreeRootItem(self.glb, self.params)
834843
835844 def columnCount(self, parent=None):
836845 return 7
@@ -1606,7 +1615,7 @@ class BranchModel(TreeModel): · 769 unmodified lines
16061615 progress = Signal(object)
16071616
16081617 def __init__(self, glb, event_id, where_clause, parent=None):
1609− super(BranchModel, self).__init__(glb, parent)
1618+ super(BranchModel, self).__init__(glb, None, parent)
16101619 self.event_id = event_id
16111620 self.more = True
16121621 self.populated = 0

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t