Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 1 | #!/usr/bin/python |
Javi Merino | c47d2df | 2015-02-06 16:04:03 +0000 | [diff] [blame] | 2 | # $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 Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 16 | |
| 17 | from base import Base |
| 18 | |
| 19 | class 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 | |
| 25 | def __init__(self, path=None): |
| 26 | super(SchedLoadAvgSchedGroup, self).__init__( |
| 27 | basepath=path, |
| 28 | unique_word=self.unique_word, |
| 29 | ) |
| 30 | |
| 31 | def finalize_object(self): |
| 32 | """This condition is necessary to force column 'cpus' to be printed |
| 33 | as 8 digits w/ leading 0 |
| 34 | """ |
| 35 | if self._cpu_mask_column in self.data_frame.columns: |
| 36 | self.data_frame[self._cpu_mask_column] = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format) |
| 37 | |
| 38 | class SchedLoadAvgTask(Base): |
| 39 | """Corresponds to Linux kernel trace event sched_load_avg_task""" |
| 40 | unique_word="sched_load_avg_task:" |
| 41 | name="sched_load_avg_task" |
| 42 | |
| 43 | def __init__(self, path=None): |
| 44 | super(SchedLoadAvgTask, self).__init__( |
| 45 | basepath=path, |
| 46 | unique_word=self.unique_word, |
| 47 | ) |
| 48 | |
| 49 | def get_pids(self, key=""): |
| 50 | """Returns a list of (comm, pid) that contain |
| 51 | 'key' in their 'comm'.""" |
| 52 | df = self.data_frame.drop_duplicates(subset=['comm','pid']).ix[:,['comm','pid']] |
| 53 | |
| 54 | return df[df['comm'].str.contains(key)].values.tolist() |
| 55 | |
| 56 | class SchedLoadAvgCpu(Base): |
| 57 | """Corresponds to Linux kernel trace event sched_load_avg_cpu""" |
| 58 | unique_word="sched_load_avg_cpu:" |
| 59 | name="sched_load_avg_cpu" |
| 60 | |
| 61 | def __init__(self, path=None): |
| 62 | super(SchedLoadAvgCpu, self).__init__( |
| 63 | basepath=path, |
| 64 | unique_word=self.unique_word, |
| 65 | ) |
| 66 | |
| 67 | class SchedContribScaleFactor(Base): |
| 68 | """Corresponds to Linux kernel trace event sched_contrib_scale_factor""" |
| 69 | unique_word="sched_contrib_scale_f:" |
| 70 | name="sched_contrib_scale_factor" |
| 71 | |
| 72 | def __init__(self, path=None): |
| 73 | super(SchedContribScaleFactor, self).__init__( |
| 74 | basepath=path, |
| 75 | unique_word=self.unique_word, |
| 76 | ) |
| 77 | |
| 78 | class SchedCpuCapacity(Base): |
| 79 | """Corresponds to Linux kernel trace event sched_cpu_capacity""" |
| 80 | unique_word="sched_cpu_capacity:" |
| 81 | name="sched_cpu_capacity" |
| 82 | |
| 83 | def __init__(self, path=None): |
| 84 | super(SchedCpuCapacity, self).__init__( |
| 85 | basepath=path, |
| 86 | unique_word=self.unique_word, |
| 87 | ) |
| 88 | |
| 89 | class SchedCpuFrequency(Base): |
| 90 | """Corresponds to Linux kernel trace event power/cpu_frequency""" |
| 91 | unique_word="cpu_frequency:" |
| 92 | name="sched_cpu_frequency" |
| 93 | |
| 94 | def __init__(self, path=None): |
| 95 | super(SchedCpuFrequency, self).__init__( |
| 96 | basepath=path, |
| 97 | unique_word=self.unique_word, |
| 98 | ) |
| 99 | |
| 100 | def finalize_object(self): |
| 101 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 102 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 103 | classes |
| 104 | """ |
| 105 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |