Use core/stats in cputop and sched, add prio_list support
[deliverable/lttng-analyses.git] / lttnganalyses / core / sched.py
index dbab32208a311dfb6860c2e1160b425576ea9a8e..df38e94603b213aeef9783f8e96f9795402d6770 100644 (file)
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-from collections import namedtuple
+from . import stats
 from .analysis import Analysis
 
 
-PrioEvent = namedtuple('PrioEvent', ['timestamp', 'prio'])
-
-
 class SchedAnalysis(Analysis):
     def __init__(self, state, conf):
         notification_cbs = {
@@ -85,11 +82,12 @@ class SchedAnalysis(Analysis):
 
         if waker_proc is not None and waker_proc.tid not in self.tids:
             self.tids[waker_proc.tid] = \
-                SchedStats.new_from_process(waker_proc)
+                ProcessSchedStats.new_from_process(waker_proc)
             self.tids[waker_proc.tid].update_prio(switch_ts, waker_proc.prio)
 
         if next_tid not in self.tids:
-            self.tids[next_tid] = SchedStats.new_from_process(wakee_proc)
+            self.tids[next_tid] = \
+                ProcessSchedStats.new_from_process(wakee_proc)
             self.tids[next_tid].update_prio(switch_ts, wakee_proc.prio)
 
         sched_event = SchedEvent(
@@ -118,19 +116,14 @@ class SchedAnalysis(Analysis):
         self.sched_list.append(sched_event)
 
 
-class SchedStats():
-    def __init__(self, tid, comm):
-        self.tid = tid
-        self.comm = comm
+class ProcessSchedStats(stats.Process):
+    def __init__(self, pid, tid, comm):
+        super().__init__(pid, tid, comm)
+
         self.min_latency = None
         self.max_latency = None
         self.total_latency = 0
         self.sched_list = []
-        self.prio_list = []
-
-    @classmethod
-    def new_from_process(cls, proc):
-        return cls(proc.tid, proc.comm)
 
     @property
     def count(self):
@@ -146,17 +139,12 @@ class SchedStats():
         self.total_latency += sched_event.latency
         self.sched_list.append(sched_event)
 
-    def update_prio(self, timestamp, prio):
-        self.prio_list.append(PrioEvent(timestamp, prio))
-
     def reset(self):
+        super().reset()
         self.min_latency = None
         self.max_latency = None
         self.total_latency = 0
         self.sched_list = []
-        if self.prio_list:
-            # Keep the last prio as the first for the next period
-            self.prio_list = self.prio_list[-1:]
 
 
 class SchedEvent():
This page took 0.038739 seconds and 5 git commands to generate.