aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/exported-sql-viewer.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
-rwxr-xr-xtools/perf/scripts/python/exported-sql-viewer.py100
1 files changed, 55 insertions, 45 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index b2a22525549d..c4a2134d85f5 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -558,26 +558,12 @@ class CallGraphRootItem(CallGraphLevelItemBase):
558 self.child_items.append(child_item) 558 self.child_items.append(child_item)
559 self.child_count += 1 559 self.child_count += 1
560 560
561# Context-sensitive call graph data model 561# Context-sensitive call graph data model base
562 562
563class CallGraphModel(TreeModel): 563class CallGraphModelBase(TreeModel):
564 564
565 def __init__(self, glb, parent=None): 565 def __init__(self, glb, parent=None):
566 super(CallGraphModel, self).__init__(glb, parent) 566 super(CallGraphModelBase, 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]
581 567
582 def FindSelect(self, value, pattern, query): 568 def FindSelect(self, value, pattern, query):
583 if pattern: 569 if pattern:
@@ -597,34 +583,7 @@ class CallGraphModel(TreeModel):
597 match = " GLOB '" + str(value) + "'" 583 match = " GLOB '" + str(value) + "'"
598 else: 584 else:
599 match = " = '" + str(value) + "'" 585 match = " = '" + str(value) + "'"
600 QueryExec(query, "SELECT call_path_id, comm_id, thread_id" 586 self.DoFindSelect(query, match)
601 " FROM calls"
602 " INNER JOIN call_paths ON calls.call_path_id = call_paths.id"
603 " INNER JOIN symbols ON call_paths.symbol_id = symbols.id"
604 " WHERE symbols.name" + match +
605 " GROUP BY comm_id, thread_id, call_path_id"
606 " ORDER BY comm_id, thread_id, call_path_id")
607
608 def FindPath(self, query):
609 # Turn the query result into a list of ids that the tree view can walk
610 # to open the tree at the right place.
611 ids = []
612 parent_id = query.value(0)
613 while parent_id:
614 ids.insert(0, parent_id)
615 q2 = QSqlQuery(self.glb.db)
616 QueryExec(q2, "SELECT parent_id"
617 " FROM call_paths"
618 " WHERE id = " + str(parent_id))
619 if not q2.next():
620 break
621 parent_id = q2.value(0)
622 # The call path root is not used
623 if ids[0] == 1:
624 del ids[0]
625 ids.insert(0, query.value(2))
626 ids.insert(0, query.value(1))
627 return ids
628 587
629 def Found(self, query, found): 588 def Found(self, query, found):
630 if found: 589 if found:
@@ -678,6 +637,57 @@ class CallGraphModel(TreeModel):
678 def FindDone(self, thread, callback, ids): 637 def FindDone(self, thread, callback, ids):
679 callback(ids) 638 callback(ids)
680 639
640# Context-sensitive call graph data model
641
642class CallGraphModel(CallGraphModelBase):
643
644 def __init__(self, glb, parent=None):
645 super(CallGraphModel, self).__init__(glb, parent)
646
647 def GetRoot(self):
648 return CallGraphRootItem(self.glb)
649
650 def columnCount(self, parent=None):
651 return 7
652
653 def columnHeader(self, column):
654 headers = ["Call Path", "Object", "Count ", "Time (ns) ", "Time (%) ", "Branch Count ", "Branch Count (%) "]
655 return headers[column]
656
657 def columnAlignment(self, column):
658 alignment = [ Qt.AlignLeft, Qt.AlignLeft, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight ]
659 return alignment[column]
660
661 def DoFindSelect(self, query, match):
662 QueryExec(query, "SELECT call_path_id, comm_id, thread_id"
663 " FROM calls"
664 " INNER JOIN call_paths ON calls.call_path_id = call_paths.id"
665 " INNER JOIN symbols ON call_paths.symbol_id = symbols.id"
666 " WHERE symbols.name" + match +
667 " GROUP BY comm_id, thread_id, call_path_id"
668 " ORDER BY comm_id, thread_id, call_path_id")
669
670 def FindPath(self, query):
671 # Turn the query result into a list of ids that the tree view can walk
672 # to open the tree at the right place.
673 ids = []
674 parent_id = query.value(0)
675 while parent_id:
676 ids.insert(0, parent_id)
677 q2 = QSqlQuery(self.glb.db)
678 QueryExec(q2, "SELECT parent_id"
679 " FROM call_paths"
680 " WHERE id = " + str(parent_id))
681 if not q2.next():
682 break
683 parent_id = q2.value(0)
684 # The call path root is not used
685 if ids[0] == 1:
686 del ids[0]
687 ids.insert(0, query.value(2))
688 ids.insert(0, query.value(1))
689 return ids
690
681# Vertical widget layout 691# Vertical widget layout
682 692
683class VBox(): 693class VBox():