Compact priority list
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 26 Feb 2016 18:02:46 +0000 (13:02 -0500)
committerJulien Desfossez <jdesfossez@efficios.com>
Fri, 26 Feb 2016 18:17:31 +0000 (13:17 -0500)
Instead of displaying the full list of priorities a process had, only
display a summary (number of time a process had each priority).

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
lttnganalyses/cli/cputop.py
lttnganalyses/cli/sched.py

index ff24f80ed45123b76b7ce61e30bc972989d2f25f..a272b6ea0b2b124b623b0726ee854634a2fdf601 100644 (file)
@@ -105,6 +105,26 @@ class Cputop(Command):
         self._mi_clear_result_tables()
         self._mi_append_result_table(summary_table)
 
+    def _cleanup_prio_list(self, prio_list):
+        prios = {}
+        prio_str = None
+        for p in prio_list:
+            if p.prio in prios:
+                prios[p.prio] += 1
+            else:
+                prios[p.prio] = 1
+        for p in sorted(prios.keys()):
+            if prios[p] > 1:
+                count_str = " (%s times)" % prios[p]
+            else:
+                count_str = ""
+            if prio_str is None:
+                prio_str = "[%s%s" % (p, count_str)
+            else:
+                prio_str = "%s, %s%s" % (prio_str, p, count_str)
+        prio_str = prio_str + "]"
+        return prio_str
+
     def _get_per_tid_usage_result_table(self, begin_ns, end_ns):
         result_table = \
             self._mi_create_result_table(self._MI_TABLE_CLASS_PER_PROC,
@@ -114,8 +134,7 @@ class Cputop(Command):
         for tid in sorted(self._analysis.tids.values(),
                           key=operator.attrgetter('usage_percent'),
                           reverse=True):
-            prio_list = str([prio_evt.prio for
-                             prio_evt in tid.prio_list])
+            prio_list = self._cleanup_prio_list(tid.prio_list)
 
             result_table.append_row(
                 process=mi.Process(tid.comm, tid=tid.tid),
index cdd4dd9bd9f6076701f6b54cb1f8999f835034aa..45389e6edbe9cdc33aef4041967538be8e0fd7a2 100644 (file)
@@ -393,6 +393,26 @@ class SchedAnalysisCommand(Command):
 
         return stats_table
 
+    def _cleanup_prio_list(self, prio_list):
+        prios = {}
+        prio_str = None
+        for p in prio_list:
+            if p.prio in prios:
+                prios[p.prio] += 1
+            else:
+                prios[p.prio] = 1
+        for p in sorted(prios.keys()):
+            if prios[p] > 1:
+                count_str = " (%s times)" % prios[p]
+            else:
+                count_str = ""
+            if prio_str is None:
+                prio_str = "[%s%s" % (p, count_str)
+            else:
+                prio_str = "%s, %s%s" % (prio_str, p, count_str)
+        prio_str = prio_str + "]"
+        return prio_str
+
     def _get_per_tid_stats_result_table(self, begin_ns, end_ns):
         stats_table = \
             self._mi_create_result_table(self._MI_TABLE_CLASS_PER_TID_STATS,
@@ -411,8 +431,7 @@ class SchedAnalysisCommand(Command):
             else:
                 stdev = mi.Duration(stdev)
 
-            prio_list = str([prio_evt.prio for
-                             prio_evt in tid_stats.prio_list])
+            prio_list = self._cleanup_prio_list(tid_stats.prio_list)
 
             stats_table.append_row(
                 process=mi.Process(tid=tid_stats.tid, name=tid_stats.comm),
@@ -809,7 +828,6 @@ class SchedAnalysisCommand(Command):
 
         graph.print_graph()
 
-
     def _print_freq(self, freq_tables):
         for freq_table in freq_tables:
             self._print_frequency_distribution(freq_table)
This page took 0.026824 seconds and 5 git commands to generate.