perf, sched migration: Librarize task states and event headers helpers
[pandora-kernel.git] / tools / perf / scripts / python / Perf-Trace-Util / lib / Perf / Trace / Core.py
index 1dc464e..aad7525 100644 (file)
@@ -89,3 +89,33 @@ def trace_flag_str(value):
            value &= ~idx
 
     return string
+
+
+def taskState(state):
+       states = {
+               0 : "R",
+               1 : "S",
+               2 : "D",
+               64: "DEAD"
+       }
+
+       if state not in states:
+               return "Unknown"
+
+       return states[state]
+
+
+class EventHeaders:
+       def __init__(self, common_cpu, common_secs, common_nsecs,
+                    common_pid, common_comm):
+               self.cpu = common_cpu
+               self.secs = common_secs
+               self.nsecs = common_nsecs
+               self.pid = common_pid
+               self.comm = common_comm
+
+       def ts(self):
+               return (self.secs * (10 ** 9)) + self.nsecs
+
+       def ts_format(self):
+               return "%d.%d" % (self.secs, int(self.nsecs / 1000))