blob: c82597531f47565e8807b67540f8c341bfbcb932 [file] [log] [blame]
Dietmar Eggemannf545f852014-12-30 11:56:22 +01001#!/usr/bin/python
2
3from base import Base
4
5class SchedLoadAvgSchedGroup(Base):
6 """Corresponds to Linux kernel trace event sched_load_avg_sched_group"""
7 unique_word="sched_load_avg_sg:"
8 name="sched_load_avg_sched_group"
9 _cpu_mask_column = "cpus"
10
11 def __init__(self, path=None):
12 super(SchedLoadAvgSchedGroup, self).__init__(
13 basepath=path,
14 unique_word=self.unique_word,
15 )
16
17 def finalize_object(self):
18 """This condition is necessary to force column 'cpus' to be printed
19 as 8 digits w/ leading 0
20 """
21 if self._cpu_mask_column in self.data_frame.columns:
22 self.data_frame[self._cpu_mask_column] = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format)
23
24class SchedLoadAvgTask(Base):
25 """Corresponds to Linux kernel trace event sched_load_avg_task"""
26 unique_word="sched_load_avg_task:"
27 name="sched_load_avg_task"
28
29 def __init__(self, path=None):
30 super(SchedLoadAvgTask, self).__init__(
31 basepath=path,
32 unique_word=self.unique_word,
33 )
34
35 def get_pids(self, key=""):
36 """Returns a list of (comm, pid) that contain
37 'key' in their 'comm'."""
38 df = self.data_frame.drop_duplicates(subset=['comm','pid']).ix[:,['comm','pid']]
39
40 return df[df['comm'].str.contains(key)].values.tolist()
41
42class SchedLoadAvgCpu(Base):
43 """Corresponds to Linux kernel trace event sched_load_avg_cpu"""
44 unique_word="sched_load_avg_cpu:"
45 name="sched_load_avg_cpu"
46
47 def __init__(self, path=None):
48 super(SchedLoadAvgCpu, self).__init__(
49 basepath=path,
50 unique_word=self.unique_word,
51 )
52
53class SchedContribScaleFactor(Base):
54 """Corresponds to Linux kernel trace event sched_contrib_scale_factor"""
55 unique_word="sched_contrib_scale_f:"
56 name="sched_contrib_scale_factor"
57
58 def __init__(self, path=None):
59 super(SchedContribScaleFactor, self).__init__(
60 basepath=path,
61 unique_word=self.unique_word,
62 )
63
64class SchedCpuCapacity(Base):
65 """Corresponds to Linux kernel trace event sched_cpu_capacity"""
66 unique_word="sched_cpu_capacity:"
67 name="sched_cpu_capacity"
68
69 def __init__(self, path=None):
70 super(SchedCpuCapacity, self).__init__(
71 basepath=path,
72 unique_word=self.unique_word,
73 )
74
75class SchedCpuFrequency(Base):
76 """Corresponds to Linux kernel trace event power/cpu_frequency"""
77 unique_word="cpu_frequency:"
78 name="sched_cpu_frequency"
79
80 def __init__(self, path=None):
81 super(SchedCpuFrequency, self).__init__(
82 basepath=path,
83 unique_word=self.unique_word,
84 )
85
86 def finalize_object(self):
87 """This renaming is necessary because our cpu related pivot is 'cpu'
88 and not 'cpu_id'. Otherwise you cannot 'mix and match' with other
89 classes
90 """
91 self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True)