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
200 200
201class TreeModel(QAbstractItemModel):201class TreeModel(QAbstractItemModel):
202 202
203 def __init__(self, glb, parent=None):203 def __init__(self, glb, params, parent=None):
204 super(TreeModel, self).__init__(parent)204 super(TreeModel, self).__init__(parent)
205 self.glb = glb205 self.glb = glb
206 self.params = params
206 self.root = self.GetRoot()207 self.root = self.GetRoot()
207 self.last_row_read = 0208 self.last_row_read = 0
208 209
@@ -463,8 +464,9 @@ class FindBar(): · 254 unmodified lines
463 464
464class CallGraphLevelItemBase(object):465class CallGraphLevelItemBase(object):
465 466
466 def __init__(self, glb, row, parent_item):467 def __init__(self, glb, params, row, parent_item):
467 self.glb = glb468 self.glb = glb
469 self.params = params
468 self.row = row470 self.row = row
469 self.parent_item = parent_item471 self.parent_item = parent_item
470 self.query_done = False;472 self.query_done = False;
@@ -503,8 +505,8 @@ class CallGraphLevelItemBase(object): · 32 unmodified lines
503 505
504class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase):506class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase):
505 507
506 def __init__(self, glb, row, comm_id, thread_id, call_path_id, time, branch_count, parent_item):508 def __init__(self, glb, params, row, comm_id, thread_id, call_path_id, time, branch_count, parent_item):
507 super(CallGraphLevelTwoPlusItemBase, self).__init__(glb, row, parent_item)509 super(CallGraphLevelTwoPlusItemBase, self).__init__(glb, params, row, parent_item)
508 self.comm_id = comm_id510 self.comm_id = comm_id
509 self.thread_id = thread_id511 self.thread_id = thread_id
510 self.call_path_id = call_path_id512 self.call_path_id = call_path_id
@@ -525,7 +527,7 @@ class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): · 14 unmodified lines
525 " GROUP BY call_path_id, name, short_name"527 " GROUP BY call_path_id, name, short_name"
526 " ORDER BY call_path_id")528 " ORDER BY call_path_id")
527 while query.next():529 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)
529 self.child_items.append(child_item)531 self.child_items.append(child_item)
530 self.child_count += 1532 self.child_count += 1
531 533
@@ -533,8 +535,8 @@ class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): · 1 unmodified line
533 535
534class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase):536class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase):
535 537
536 def __init__(self, glb, row, comm_id, thread_id, call_path_id, name, dso, count, 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):
537 super(CallGraphLevelThreeItem, self).__init__(glb, row, comm_id, thread_id, call_path_id, 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)
538 dso = dsoname(dso)540 dso = dsoname(dso)
539 self.data = [ name, dso, str(count), str(time), PercentToOneDP(time, parent_item.time), str(branch_count), PercentToOneDP(branch_count, parent_item.branch_count) ]541 self.data = [ name, dso, str(count), str(time), PercentToOneDP(time, parent_item.time), str(branch_count), PercentToOneDP(branch_count, parent_item.branch_count) ]
540 self.dbid = call_path_id542 self.dbid = call_path_id
@@ -543,8 +545,8 @@ class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase): · 2 unmodified lines
543 545
544class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase):546class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase):
545 547
546 def __init__(self, glb, row, comm_id, thread_id, pid, tid, parent_item):548 def __init__(self, glb, params, 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)549 super(CallGraphLevelTwoItem, self).__init__(glb, params, row, comm_id, thread_id, 1, 0, 0, parent_item)
548 self.data = [str(pid) + ":" + str(tid), "", "", "", "", "", ""]550 self.data = [str(pid) + ":" + str(tid), "", "", "", "", "", ""]
549 self.dbid = thread_id551 self.dbid = thread_id
550 552
@@ -561,8 +563,8 @@ class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase): · 10 unmodified lines
561 563
562class CallGraphLevelOneItem(CallGraphLevelItemBase):564class CallGraphLevelOneItem(CallGraphLevelItemBase):
563 565
564 def __init__(self, glb, row, comm_id, comm, parent_item):566 def __init__(self, glb, params, row, comm_id, comm, parent_item):
565 super(CallGraphLevelOneItem, self).__init__(glb, row, parent_item)567 super(CallGraphLevelOneItem, self).__init__(glb, params, row, parent_item)
566 self.data = [comm, "", "", "", "", "", ""]568 self.data = [comm, "", "", "", "", "", ""]
567 self.dbid = comm_id569 self.dbid = comm_id
568 570
@@ -574,7 +576,7 @@ class CallGraphLevelOneItem(CallGraphLevelItemBase): · 5 unmodified lines
574 " INNER JOIN threads ON thread_id = threads.id"576 " INNER JOIN threads ON thread_id = threads.id"
575 " WHERE comm_id = " + str(self.dbid))577 " WHERE comm_id = " + str(self.dbid))
576 while query.next():578 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)
578 self.child_items.append(child_item)580 self.child_items.append(child_item)
579 self.child_count += 1581 self.child_count += 1
580 582
@@ -582,8 +584,8 @@ class CallGraphLevelOneItem(CallGraphLevelItemBase): · 1 unmodified line
582 584
583class CallGraphRootItem(CallGraphLevelItemBase):585class CallGraphRootItem(CallGraphLevelItemBase):
584 586
585 def __init__(self, glb):587 def __init__(self, glb, params):
586 super(CallGraphRootItem, self).__init__(glb, 0, None)588 super(CallGraphRootItem, self).__init__(glb, params, 0, None)
587 self.dbid = 0589 self.dbid = 0
588 self.query_done = True;590 self.query_done = True;
589 query = QSqlQuery(glb.db)591 query = QSqlQuery(glb.db)
@@ -591,16 +593,23 @@ class CallGraphRootItem(CallGraphLevelItemBase): · 1 unmodified line
591 while query.next():593 while query.next():
592 if not query.value(0):594 if not query.value(0):
593 continue595 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)
595 self.child_items.append(child_item)597 self.child_items.append(child_item)
596 self.child_count += 1598 self.child_count += 1
597 599
600# Call graph model parameters
601
602class CallGraphModelParams():
603
604 def __init__(self, glb, parent=None):
605 self.have_ipc = IsSelectable(glb.db, "calls", columns = "insn_count, cyc_count")
606
598# Context-sensitive call graph data model base607# Context-sensitive call graph data model base
599 608
600class CallGraphModelBase(TreeModel):609class CallGraphModelBase(TreeModel):
601 610
602 def __init__(self, glb, parent=None):611 def __init__(self, glb, parent=None):
603 super(CallGraphModelBase, self).__init__(glb, parent)612 super(CallGraphModelBase, self).__init__(glb, CallGraphModelParams(glb), parent)
604 613
605 def FindSelect(self, value, pattern, query):614 def FindSelect(self, value, pattern, query):
606 if pattern:615 if pattern:
@@ -682,7 +691,7 @@ class CallGraphModel(CallGraphModelBase): · 75 unmodified lines
682 super(CallGraphModel, self).__init__(glb, parent)691 super(CallGraphModel, self).__init__(glb, parent)
683 692
684 def GetRoot(self):693 def GetRoot(self):
685 return CallGraphRootItem(self.glb)694 return CallGraphRootItem(self.glb, self.params)
686 695
687 def columnCount(self, parent=None):696 def columnCount(self, parent=None):
688 return 7697 return 7
@@ -729,8 +738,8 @@ class CallGraphModel(CallGraphModelBase): · 40 unmodified lines
729 738
730class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase):739class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase):
731 740
732 def __init__(self, glb, row, comm_id, thread_id, calls_id, time, branch_count, parent_item):741 def __init__(self, glb, params, row, comm_id, thread_id, calls_id, time, branch_count, parent_item):
733 super(CallTreeLevelTwoPlusItemBase, self).__init__(glb, row, parent_item)742 super(CallTreeLevelTwoPlusItemBase, self).__init__(glb, params, row, parent_item)
734 self.comm_id = comm_id743 self.comm_id = comm_id
735 self.thread_id = thread_id744 self.thread_id = thread_id
736 self.calls_id = calls_id745 self.calls_id = calls_id
@@ -752,7 +761,7 @@ class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): · 15 unmodified lines
752 " WHERE calls.parent_id = " + str(self.calls_id) + comm_thread +761 " WHERE calls.parent_id = " + str(self.calls_id) + comm_thread +
753 " ORDER BY call_time, calls.id")762 " ORDER BY call_time, calls.id")
754 while query.next():763 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)
756 self.child_items.append(child_item)765 self.child_items.append(child_item)
757 self.child_count += 1766 self.child_count += 1
758 767
@@ -760,8 +769,8 @@ class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): · 1 unmodified line
760 769
761class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase):770class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase):
762 771
763 def __init__(self, glb, row, comm_id, thread_id, calls_id, name, dso, count, 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):
764 super(CallTreeLevelThreeItem, self).__init__(glb, row, comm_id, thread_id, calls_id, time, branch_count, parent_item)773 super(CallTreeLevelThreeItem, self).__init__(glb, params, row, comm_id, thread_id, calls_id, time, branch_count, parent_item)
765 dso = dsoname(dso)774 dso = dsoname(dso)
766 self.data = [ name, dso, str(count), str(time), PercentToOneDP(time, parent_item.time), str(branch_count), PercentToOneDP(branch_count, parent_item.branch_count) ]775 self.data = [ name, dso, str(count), str(time), PercentToOneDP(time, parent_item.time), str(branch_count), PercentToOneDP(branch_count, parent_item.branch_count) ]
767 self.dbid = calls_id776 self.dbid = calls_id
@@ -770,8 +779,8 @@ class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase): · 2 unmodified lines
770 779
771class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase):780class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase):
772 781
773 def __init__(self, glb, row, comm_id, thread_id, pid, tid, parent_item):782 def __init__(self, glb, params, 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)783 super(CallTreeLevelTwoItem, self).__init__(glb, params, row, comm_id, thread_id, 0, 0, 0, parent_item)
775 self.data = [str(pid) + ":" + str(tid), "", "", "", "", "", ""]784 self.data = [str(pid) + ":" + str(tid), "", "", "", "", "", ""]
776 self.dbid = thread_id785 self.dbid = thread_id
777 786
@@ -788,8 +797,8 @@ class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase): · 10 unmodified lines
788 797
789class CallTreeLevelOneItem(CallGraphLevelItemBase):798class CallTreeLevelOneItem(CallGraphLevelItemBase):
790 799
791 def __init__(self, glb, row, comm_id, comm, parent_item):800 def __init__(self, glb, params, row, comm_id, comm, parent_item):
792 super(CallTreeLevelOneItem, self).__init__(glb, row, parent_item)801 super(CallTreeLevelOneItem, self).__init__(glb, params, row, parent_item)
793 self.data = [comm, "", "", "", "", "", ""]802 self.data = [comm, "", "", "", "", "", ""]
794 self.dbid = comm_id803 self.dbid = comm_id
795 804
@@ -801,7 +810,7 @@ class CallTreeLevelOneItem(CallGraphLevelItemBase): · 5 unmodified lines
801 " INNER JOIN threads ON thread_id = threads.id"810 " INNER JOIN threads ON thread_id = threads.id"
802 " WHERE comm_id = " + str(self.dbid))811 " WHERE comm_id = " + str(self.dbid))
803 while query.next():812 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)
805 self.child_items.append(child_item)814 self.child_items.append(child_item)
806 self.child_count += 1815 self.child_count += 1
807 816
@@ -809,8 +818,8 @@ class CallTreeLevelOneItem(CallGraphLevelItemBase): · 1 unmodified line
809 818
810class CallTreeRootItem(CallGraphLevelItemBase):819class CallTreeRootItem(CallGraphLevelItemBase):
811 820
812 def __init__(self, glb):821 def __init__(self, glb, params):
813 super(CallTreeRootItem, self).__init__(glb, 0, None)822 super(CallTreeRootItem, self).__init__(glb, params, 0, None)
814 self.dbid = 0823 self.dbid = 0
815 self.query_done = True;824 self.query_done = True;
816 query = QSqlQuery(glb.db)825 query = QSqlQuery(glb.db)
@@ -818,7 +827,7 @@ class CallTreeRootItem(CallGraphLevelItemBase): · 1 unmodified line
818 while query.next():827 while query.next():
819 if not query.value(0):828 if not query.value(0):
820 continue829 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)
822 self.child_items.append(child_item)831 self.child_items.append(child_item)
823 self.child_count += 1832 self.child_count += 1
824 833
@@ -830,7 +839,7 @@ class CallTreeModel(CallGraphModelBase): · 5 unmodified lines
830 super(CallTreeModel, self).__init__(glb, parent)839 super(CallTreeModel, self).__init__(glb, parent)
831 840
832 def GetRoot(self):841 def GetRoot(self):
833 return CallTreeRootItem(self.glb)842 return CallTreeRootItem(self.glb, self.params)
834 843
835 def columnCount(self, parent=None):844 def columnCount(self, parent=None):
836 return 7845 return 7
@@ -1606,7 +1615,7 @@ class BranchModel(TreeModel): · 769 unmodified lines
1606 progress = Signal(object)1615 progress = Signal(object)
1607 1616
1608 def __init__(self, glb, event_id, where_clause, parent=None):1617 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)
1610 self.event_id = event_id1619 self.event_id = event_id
1611 self.more = True1620 self.more = True
1612 self.populated = 01621 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