[gimp] tools: a few improvements in performance-log-viewer.py



commit 0b2d41635ab7b2c158925fa11a6537fdfb4af046
Author: Ell <ell_se yahoo com>
Date:   Wed Nov 7 13:59:36 2018 -0500

    tools: a few improvements in performance-log-viewer.py
    
    In sample-search predicates, remove the "exclusive" parameter of
    the "function()" function, and replace it with optional "id" and
    "state" parameters, which limit the match to the call-stacks of
    matching threads, as per the "thread()" function.
    
    Sort the backtrace thread-list by thread ID.

 tools/performance-log-viewer.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/tools/performance-log-viewer.py b/tools/performance-log-viewer.py
index 941ec410b1..db934a5983 100755
--- a/tools/performance-log-viewer.py
+++ b/tools/performance-log-viewer.py
@@ -726,23 +726,22 @@ class FindSamplesPopover (Gtk.Popover):
 
         for i in range (len (samples)):
             try:
-                def thread (id, state = None):
-                    for thread in samples[i].backtrace or []:
-                        if (type (id) == int and id == thread.id) or \
-                           (type (id) == str and thread.name and \
-                            re.fullmatch (id, thread.name)):
-                            if state is None or \
-                               re.fullmatch (state, str (thread.state)):
-                                return True
+                def match_thread (thread, id, state = None):
+                    return (type (id) == int                and \
+                            id == thread.id)                or  \
+                           (type (id) == str                and \
+                            thread.name                     and \
+                            re.fullmatch (id, thread.name)) and \
+                           (state is None                   or  \
+                            re.fullmatch (state, str (thread.state)))
 
-                    return False
+                def thread (id, state = None):
+                    return any (match_thread (thread, id, state)
+                                for thread in samples[i].backtrace or [])
 
-                def function (name, exclusive = False):
+                def function (name, id = None, state = None):
                     for thread in samples[i].backtrace or []:
-                        if exclusive:
-                            if re.fullmatch (name, thread.frames[0].info.name):
-                                return True
-                        else:
+                        if match_thread (thread, id, state):
                             for frame in thread.frames:
                                 if re.fullmatch (name, frame.info.name):
                                     return True
@@ -1887,6 +1886,7 @@ class BacktraceViewer (Gtk.Box):
 
         store = self.ThreadStore ()
         self.thread_store = store
+        store.set_sort_column_id (store.ID, Gtk.SortType.ASCENDING)
 
         tree = Gtk.TreeView (model = store)
         self.thread_tree = tree


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]