Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase

Factor out a base class CallGraphModelBase from CallGraphModel, so that
CallGraphModelBase can be reused.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lkml.kernel.org/n/tip-76eybebzjwvgnadkm2oufrqi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
254c0d82 a448ba23

+55 -45
+55 -45
tools/perf/scripts/python/exported-sql-viewer.py
··· 558 558 self.child_items.append(child_item) 559 559 self.child_count += 1 560 560 561 - # Context-sensitive call graph data model 561 + # Context-sensitive call graph data model base 562 562 563 - class CallGraphModel(TreeModel): 563 + class CallGraphModelBase(TreeModel): 564 564 565 565 def __init__(self, glb, parent=None): 566 - super(CallGraphModel, self).__init__(glb, parent) 567 - 568 - def GetRoot(self): 569 - return CallGraphRootItem(self.glb) 570 - 571 - def columnCount(self, parent=None): 572 - return 7 573 - 574 - def columnHeader(self, column): 575 - headers = ["Call Path", "Object", "Count ", "Time (ns) ", "Time (%) ", "Branch Count ", "Branch Count (%) "] 576 - return headers[column] 577 - 578 - def columnAlignment(self, column): 579 - alignment = [ Qt.AlignLeft, Qt.AlignLeft, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight ] 580 - return alignment[column] 566 + super(CallGraphModelBase, self).__init__(glb, parent) 581 567 582 568 def FindSelect(self, value, pattern, query): 583 569 if pattern: ··· 583 597 match = " GLOB '" + str(value) + "'" 584 598 else: 585 599 match = " = '" + str(value) + "'" 586 - QueryExec(query, "SELECT call_path_id, comm_id, thread_id" 587 - " FROM calls" 588 - " INNER JOIN call_paths ON calls.call_path_id = call_paths.id" 589 - " INNER JOIN symbols ON call_paths.symbol_id = symbols.id" 590 - " WHERE symbols.name" + match + 591 - " GROUP BY comm_id, thread_id, call_path_id" 592 - " ORDER BY comm_id, thread_id, call_path_id") 593 - 594 - def FindPath(self, query): 595 - # Turn the query result into a list of ids that the tree view can walk 596 - # to open the tree at the right place. 597 - ids = [] 598 - parent_id = query.value(0) 599 - while parent_id: 600 - ids.insert(0, parent_id) 601 - q2 = QSqlQuery(self.glb.db) 602 - QueryExec(q2, "SELECT parent_id" 603 - " FROM call_paths" 604 - " WHERE id = " + str(parent_id)) 605 - if not q2.next(): 606 - break 607 - parent_id = q2.value(0) 608 - # The call path root is not used 609 - if ids[0] == 1: 610 - del ids[0] 611 - ids.insert(0, query.value(2)) 612 - ids.insert(0, query.value(1)) 613 - return ids 600 + self.DoFindSelect(query, match) 614 601 615 602 def Found(self, query, found): 616 603 if found: ··· 636 677 637 678 def FindDone(self, thread, callback, ids): 638 679 callback(ids) 680 + 681 + # Context-sensitive call graph data model 682 + 683 + class CallGraphModel(CallGraphModelBase): 684 + 685 + def __init__(self, glb, parent=None): 686 + super(CallGraphModel, self).__init__(glb, parent) 687 + 688 + def GetRoot(self): 689 + return CallGraphRootItem(self.glb) 690 + 691 + def columnCount(self, parent=None): 692 + return 7 693 + 694 + def columnHeader(self, column): 695 + headers = ["Call Path", "Object", "Count ", "Time (ns) ", "Time (%) ", "Branch Count ", "Branch Count (%) "] 696 + return headers[column] 697 + 698 + def columnAlignment(self, column): 699 + alignment = [ Qt.AlignLeft, Qt.AlignLeft, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight ] 700 + return alignment[column] 701 + 702 + def DoFindSelect(self, query, match): 703 + QueryExec(query, "SELECT call_path_id, comm_id, thread_id" 704 + " FROM calls" 705 + " INNER JOIN call_paths ON calls.call_path_id = call_paths.id" 706 + " INNER JOIN symbols ON call_paths.symbol_id = symbols.id" 707 + " WHERE symbols.name" + match + 708 + " GROUP BY comm_id, thread_id, call_path_id" 709 + " ORDER BY comm_id, thread_id, call_path_id") 710 + 711 + def FindPath(self, query): 712 + # Turn the query result into a list of ids that the tree view can walk 713 + # to open the tree at the right place. 714 + ids = [] 715 + parent_id = query.value(0) 716 + while parent_id: 717 + ids.insert(0, parent_id) 718 + q2 = QSqlQuery(self.glb.db) 719 + QueryExec(q2, "SELECT parent_id" 720 + " FROM call_paths" 721 + " WHERE id = " + str(parent_id)) 722 + if not q2.next(): 723 + break 724 + parent_id = q2.value(0) 725 + # The call path root is not used 726 + if ids[0] == 1: 727 + del ids[0] 728 + ids.insert(0, query.value(2)) 729 + ids.insert(0, query.value(1)) 730 + return ids 639 731 640 732 # Vertical widget layout 641 733