diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2019-05-20 07:37:25 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-05 08:47:57 -0400 |
commit | 4a0979d4b4feee67a7f9a5605b5bfae3b0a2b6a9 (patch) | |
tree | ef2124fa7c8bec350bf5d5db4bd100bf41bf7673 /tools/perf/scripts/python/exported-sql-viewer.py | |
parent | 530e22fd5c6d2c572b1bbdda23eafa01a005fce0 (diff) |
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.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190520113728.14389-20-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
-rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index a607235c8cd9..b3508bd4eb00 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
@@ -200,9 +200,10 @@ class Thread(QThread): | |||
200 | 200 | ||
201 | class TreeModel(QAbstractItemModel): | 201 | class 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 = glb | 205 | self.glb = glb |
206 | self.params = params | ||
206 | self.root = self.GetRoot() | 207 | self.root = self.GetRoot() |
207 | self.last_row_read = 0 | 208 | self.last_row_read = 0 |
208 | 209 | ||
@@ -463,8 +464,9 @@ class FindBar(): | |||
463 | 464 | ||
464 | class CallGraphLevelItemBase(object): | 465 | class CallGraphLevelItemBase(object): |
465 | 466 | ||
466 | def __init__(self, glb, row, parent_item): | 467 | def __init__(self, glb, params, row, parent_item): |
467 | self.glb = glb | 468 | self.glb = glb |
469 | self.params = params | ||
468 | self.row = row | 470 | self.row = row |
469 | self.parent_item = parent_item | 471 | self.parent_item = parent_item |
470 | self.query_done = False; | 472 | self.query_done = False; |
@@ -503,8 +505,8 @@ class CallGraphLevelItemBase(object): | |||
503 | 505 | ||
504 | class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): | 506 | class 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_id | 510 | self.comm_id = comm_id |
509 | self.thread_id = thread_id | 511 | self.thread_id = thread_id |
510 | self.call_path_id = call_path_id | 512 | self.call_path_id = call_path_id |
@@ -525,7 +527,7 @@ class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): | |||
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 += 1 | 532 | self.child_count += 1 |
531 | 533 | ||
@@ -533,8 +535,8 @@ class CallGraphLevelTwoPlusItemBase(CallGraphLevelItemBase): | |||
533 | 535 | ||
534 | class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase): | 536 | class 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_id | 542 | self.dbid = call_path_id |
@@ -543,8 +545,8 @@ class CallGraphLevelThreeItem(CallGraphLevelTwoPlusItemBase): | |||
543 | 545 | ||
544 | class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase): | 546 | class 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_id | 551 | self.dbid = thread_id |
550 | 552 | ||
@@ -561,8 +563,8 @@ class CallGraphLevelTwoItem(CallGraphLevelTwoPlusItemBase): | |||
561 | 563 | ||
562 | class CallGraphLevelOneItem(CallGraphLevelItemBase): | 564 | class 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_id | 569 | self.dbid = comm_id |
568 | 570 | ||
@@ -574,7 +576,7 @@ class CallGraphLevelOneItem(CallGraphLevelItemBase): | |||
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 += 1 | 581 | self.child_count += 1 |
580 | 582 | ||
@@ -582,8 +584,8 @@ class CallGraphLevelOneItem(CallGraphLevelItemBase): | |||
582 | 584 | ||
583 | class CallGraphRootItem(CallGraphLevelItemBase): | 585 | class 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 = 0 | 589 | 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): | |||
591 | while query.next(): | 593 | while query.next(): |
592 | if not query.value(0): | 594 | if not query.value(0): |
593 | continue | 595 | 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 += 1 | 598 | self.child_count += 1 |
597 | 599 | ||
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 | |||
598 | # Context-sensitive call graph data model base | 607 | # Context-sensitive call graph data model base |
599 | 608 | ||
600 | class CallGraphModelBase(TreeModel): | 609 | class 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): | |||
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 7 | 697 | return 7 |
@@ -729,8 +738,8 @@ class CallGraphModel(CallGraphModelBase): | |||
729 | 738 | ||
730 | class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): | 739 | class 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_id | 743 | self.comm_id = comm_id |
735 | self.thread_id = thread_id | 744 | self.thread_id = thread_id |
736 | self.calls_id = calls_id | 745 | self.calls_id = calls_id |
@@ -752,7 +761,7 @@ class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): | |||
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 += 1 | 766 | self.child_count += 1 |
758 | 767 | ||
@@ -760,8 +769,8 @@ class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): | |||
760 | 769 | ||
761 | class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase): | 770 | class 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_id | 776 | self.dbid = calls_id |
@@ -770,8 +779,8 @@ class CallTreeLevelThreeItem(CallTreeLevelTwoPlusItemBase): | |||
770 | 779 | ||
771 | class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase): | 780 | class 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_id | 785 | self.dbid = thread_id |
777 | 786 | ||
@@ -788,8 +797,8 @@ class CallTreeLevelTwoItem(CallTreeLevelTwoPlusItemBase): | |||
788 | 797 | ||
789 | class CallTreeLevelOneItem(CallGraphLevelItemBase): | 798 | class 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_id | 803 | self.dbid = comm_id |
795 | 804 | ||
@@ -801,7 +810,7 @@ class CallTreeLevelOneItem(CallGraphLevelItemBase): | |||
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 += 1 | 815 | self.child_count += 1 |
807 | 816 | ||
@@ -809,8 +818,8 @@ class CallTreeLevelOneItem(CallGraphLevelItemBase): | |||
809 | 818 | ||
810 | class CallTreeRootItem(CallGraphLevelItemBase): | 819 | class 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 = 0 | 823 | 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): | |||
818 | while query.next(): | 827 | while query.next(): |
819 | if not query.value(0): | 828 | if not query.value(0): |
820 | continue | 829 | 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 += 1 | 832 | self.child_count += 1 |
824 | 833 | ||
@@ -830,7 +839,7 @@ class CallTreeModel(CallGraphModelBase): | |||
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 7 | 845 | return 7 |
@@ -1606,7 +1615,7 @@ class BranchModel(TreeModel): | |||
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_id | 1619 | self.event_id = event_id |
1611 | self.more = True | 1620 | self.more = True |
1612 | self.populated = 0 | 1621 | self.populated = 0 |