blob: 965a47b5ea2f3a57199e02e10139c5aca7305707 [file] [log] [blame]
Dietmar Eggemannf545f852014-12-30 11:56:22 +01001#!/usr/bin/python
Javi Merinoc47d2df2015-02-06 16:04:03 +00002# $Copyright:
3# ----------------------------------------------------------------
4# This confidential and proprietary software may be used only as
5# authorised by a licensing agreement from ARM Limited
6# (C) COPYRIGHT 2015 ARM Limited
7# ALL RIGHTS RESERVED
8# The entire notice above must be reproduced on all authorised
9# copies and copies may only be made to the extent permitted
10# by a licensing agreement from ARM Limited.
11# ----------------------------------------------------------------
12# File: sched.py
13# ----------------------------------------------------------------
14# $
15#
Dietmar Eggemannf545f852014-12-30 11:56:22 +010016
17from base import Base
18
19class SchedLoadAvgSchedGroup(Base):
20 """Corresponds to Linux kernel trace event sched_load_avg_sched_group"""
21 unique_word="sched_load_avg_sg:"
22 name="sched_load_avg_sched_group"
23 _cpu_mask_column = "cpus"
24
Javi Merino6f34d902015-02-21 11:39:09 +000025 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010026 super(SchedLoadAvgSchedGroup, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010027 unique_word=self.unique_word,
28 )
29
30 def finalize_object(self):
31 """This condition is necessary to force column 'cpus' to be printed
32 as 8 digits w/ leading 0
33 """
34 if self._cpu_mask_column in self.data_frame.columns:
35 self.data_frame[self._cpu_mask_column] = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format)
36
37class SchedLoadAvgTask(Base):
38 """Corresponds to Linux kernel trace event sched_load_avg_task"""
39 unique_word="sched_load_avg_task:"
40 name="sched_load_avg_task"
41
Javi Merino6f34d902015-02-21 11:39:09 +000042 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010043 super(SchedLoadAvgTask, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010044 unique_word=self.unique_word,
45 )
46
47 def get_pids(self, key=""):
48 """Returns a list of (comm, pid) that contain
49 'key' in their 'comm'."""
50 df = self.data_frame.drop_duplicates(subset=['comm','pid']).ix[:,['comm','pid']]
51
52 return df[df['comm'].str.contains(key)].values.tolist()
53
54class SchedLoadAvgCpu(Base):
55 """Corresponds to Linux kernel trace event sched_load_avg_cpu"""
56 unique_word="sched_load_avg_cpu:"
57 name="sched_load_avg_cpu"
58
Javi Merino6f34d902015-02-21 11:39:09 +000059 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010060 super(SchedLoadAvgCpu, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010061 unique_word=self.unique_word,
62 )
63
64class SchedContribScaleFactor(Base):
65 """Corresponds to Linux kernel trace event sched_contrib_scale_factor"""
66 unique_word="sched_contrib_scale_f:"
67 name="sched_contrib_scale_factor"
68
Javi Merino6f34d902015-02-21 11:39:09 +000069 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010070 super(SchedContribScaleFactor, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010071 unique_word=self.unique_word,
72 )
73
74class SchedCpuCapacity(Base):
75 """Corresponds to Linux kernel trace event sched_cpu_capacity"""
76 unique_word="sched_cpu_capacity:"
77 name="sched_cpu_capacity"
78
Javi Merino6f34d902015-02-21 11:39:09 +000079 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010080 super(SchedCpuCapacity, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010081 unique_word=self.unique_word,
82 )
83
84class SchedCpuFrequency(Base):
85 """Corresponds to Linux kernel trace event power/cpu_frequency"""
86 unique_word="cpu_frequency:"
87 name="sched_cpu_frequency"
88
Javi Merino6f34d902015-02-21 11:39:09 +000089 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010090 super(SchedCpuFrequency, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010091 unique_word=self.unique_word,
92 )
93
94 def finalize_object(self):
95 """This renaming is necessary because our cpu related pivot is 'cpu'
96 and not 'cpu_id'. Otherwise you cannot 'mix and match' with other
97 classes
98 """
99 self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True)