Use core/stats in cputop and sched, add prio_list support
[deliverable/lttng-analyses.git] / lttnganalyses / core / stats.py
index 8c15567a67149bb3d130b2e2caf062fc94708433..df0de09d005ca7e8926e5fdf8088408e51d975fb 100644 (file)
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
+from collections import namedtuple
+
+
+PrioEvent = namedtuple('PrioEvent', ['timestamp', 'prio'])
+
+
 class Stats():
     def reset(self):
         raise NotImplementedError()
@@ -30,11 +36,20 @@ class Process(Stats):
         self.pid = pid
         self.tid = tid
         self.comm = comm
+        self.prio_list = []
 
     @classmethod
     def new_from_process(cls, proc):
         return cls(proc.pid, proc.tid, proc.comm)
 
+    def update_prio(self, timestamp, prio):
+        self.prio_list.append(PrioEvent(timestamp, prio))
+
+    def reset(self):
+        if self.prio_list:
+            # Keep the last prio as the first for the next period
+            self.prio_list = self.prio_list[-1:]
+
 
 class IO(Stats):
     def __init__(self):
This page took 0.023766 seconds and 5 git commands to generate.