def register_class(cls): """Register a new class implementation Should be used when the class has complex helper methods and does not expect to use the default constructor """ # Check the argspec of the class Run.register_class(cls)
def register_class(cls): """Register a new class implementation Should be used when the class has complex helper methods and does not expect to use the default constructor :param cls: The class to be registered for enabling the parsing of an event in trace :type cls: :mod:`trappy.base.Base` """ # Check the argspec of the class Run.register_class(cls)
def register_dynamic(class_name, unique_word, scope="all", parse_raw=False): """Create a Dynamic Type and register it with the trappy Framework""" dyn_class = DynamicTypeFactory( class_name, (Base, ), { "__init__": default_init, "unique_word": unique_word, "name": _get_name(class_name), "parse_raw": parse_raw }) Run.register_class(dyn_class, scope) return dyn_class
def register_dynamic(class_name, unique_word, scope="all", parse_raw=False): """Create a Dynamic Type and register it with the TRAPpy Framework :param class_name: The name of the class to be registered (Should be in CamelCase) :type class_name: str :param unique_word: The unique_word to be matched in the trace :type unique_word: str :param scope: Registry Scope (Can be used to constrain the parsing of events and group them together) :type scope: str :param parse_raw: If, true, raw trace output (-R flag) will be used :type parse_raw: bool For example if a new unique word :code:`my_unique_word` has to be registered with TRAPpy: :: import trappy custom_class = trappy.register_dynamic("MyEvent", "my_unique_word") run = trappy.Run("/path/to/trace_file") # New data member created in the run object run.my_event .. note:: The name of the member is :code:`my_event` from **MyEvent** :return: A class object of type :mod:`trappy.base.Base` """ dyn_class = DynamicTypeFactory( class_name, (Base,), { "__init__": default_init, "unique_word": unique_word, "name": _get_name(class_name), "parse_raw" : parse_raw } ) Run.register_class(dyn_class, scope) return dyn_class
def register_dynamic(class_name, unique_word, scope="all", parse_raw=False): """Create a Dynamic Type and register it with the TRAPpy Framework :param class_name: The name of the class to be registered (Should be in CamelCase) :type class_name: str :param unique_word: The unique_word to be matched in the trace :type unique_word: str :param scope: Registry Scope (Can be used to constrain the parsing of events and group them together) :type scope: str :param parse_raw: If, true, raw trace output (-R flag) will be used :type parse_raw: bool For example if a new unique word :code:`my_unique_word` has to be registered with TRAPpy: :: import trappy custom_class = trappy.register_dynamic("MyEvent", "my_unique_word") run = trappy.Run("/path/to/trace_file") # New data member created in the run object run.my_event .. note:: The name of the member is :code:`my_event` from **MyEvent** :return: A class object of type :mod:`trappy.base.Base` """ dyn_class = DynamicTypeFactory( class_name, (Base, ), { "__init__": default_init, "unique_word": unique_word, "name": _get_name(class_name), "parse_raw": parse_raw }) Run.register_class(dyn_class, scope) return dyn_class
def get_all_freqs(self, mapping_label): """Get a :mod:`pandas.DataFrame` with the maximum frequencies allowed by the governor :param mapping_label: A dictionary that maps cpumasks to name of the cpu. :type mapping_label: dict :return: freqs are in MHz """ dfr = self.data_frame return pivot_with_labels(dfr, "freq", "cpus", mapping_label) / 1000 Run.register_class(CpuOutPower, "thermal") class CpuInPower(Base): """Process the cpufreq cooling power actor data in a ftrace dump """ unique_word = "thermal_power_cpu_get" """The unique word that will be matched in a trace line""" name = "cpu_in_power" """The name of the :mod:`pandas.DataFrame` member that will be created in a :mod:`trappy.run.Run` object""" pivot = "cpus" """The Pivot along which the data is orthogonal"""
:param ax: Axis instance :type ax: :mod:`matplotlib.Axis` :param title: The title of the plot :type title: str """ temps = self.data_frame["temp"] / 1000 title = normalize_title("Temperature", title) xlim = (0, temps.max()) plot_hist(temps, ax, title, "C", 30, "Temperature", xlim, "default") Run.register_class(Thermal, "thermal") class ThermalGovernor(Base): """Process the power allocator data in a ftrace dump""" unique_word = "thermal_power_allocator:" """The unique word that will be matched in a trace line""" name = "thermal_governor" """The name of the :mod:`pandas.DataFrame` member that will be created in a :mod:`trappy.run.Run` object""" pivot = "thermal_zone_id" """The Pivot along which the data is orthogonal""" def __init__(self):
"""Plot a temperature histogram :param ax: Axis instance :type ax: :mod:`matplotlib.Axis` :param title: The title of the plot :type title: str """ temps = self.data_frame["temp"] / 1000 title = normalize_title("Temperature", title) xlim = (0, temps.max()) plot_hist(temps, ax, title, "C", 30, "Temperature", xlim, "default") Run.register_class(Thermal, "thermal") class ThermalGovernor(Base): """Process the power allocator data in a ftrace dump""" unique_word = "thermal_power_allocator:" """The unique word that will be matched in a trace line""" name = "thermal_governor" """The name of the :mod:`pandas.DataFrame` member that will be created in a :mod:`trappy.run.Run` object""" pivot = "thermal_zone_id" """The Pivot along which the data is orthogonal""" def __init__(self):
_cpu_mask_column = "cpus" def __init__(self): super(SchedLoadAvgSchedGroup, self).__init__( unique_word=self.unique_word, ) def finalize_object(self): """This condition is necessary to force column 'cpus' to be printed as 8 digits w/ leading 0 """ if self._cpu_mask_column in self.data_frame.columns: dfr = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format) self.data_frame[self._cpu_mask_column] = dfr Run.register_class(SchedLoadAvgSchedGroup, "sched") class SchedLoadAvgTask(Base): """Corresponds to Linux kernel trace event sched_load_avg_task""" unique_word = "sched_load_avg_task:" """The unique word that will be matched in a trace line""" name = "sched_load_avg_task" """The name of the :mod:`pandas.DataFrame` member that will be created in a :mod:`trappy.run.Run` object""" def __init__(self): super(SchedLoadAvgTask, self).__init__( unique_word=self.unique_word, )
"""The Pivot along which the data is orthogonal""" def __init__(self): super(PIDController, self).__init__(unique_word="thermal_power_allocator_pid", ) def plot_controller(self, title="", width=None, height=None, ax=None): """Plot a summary of the controller data :param ax: Axis instance :type ax: :mod:`matplotlib.Axis` :param title: The title of the plot :type title: str :param width: The width of the plot :type width: int :param height: The height of the plot :type int: int """ title = normalize_title("PID", title) if not ax: ax = pre_plot_setup(width, height) self.data_frame[["output", "p", "i", "d"]].plot(ax=ax) post_plot_setup(ax, title=title) Run.register_class(PIDController, "thermal")
self).__init__(unique_word="thermal_power_devfreq_get_power:", ) def get_all_freqs(self): """Return a :mod:`pandas.DataFrame` with the frequencies for the devfreq device The format should be the same as the one for :code:`CpuInPower().get_all_freqs()`. .. note:: Frequencies are in MHz. """ return pd.DataFrame(self.data_frame["freq"] / 1000000) Run.register_class(DevfreqInPower, "thermal") class DevfreqOutPower(Base): """Process de devfreq cooling device data regarding power2state in an ftrace dump""" name = "devfreq_out_power" """The name of the :mod:`pandas.DataFrame` member that will be created in a :mod:`trappy.run.Run` object""" def __init__(self): super(DevfreqOutPower, self).__init__(unique_word="thermal_power_devfreq_limit:", ) def get_all_freqs(self): """Return a :mod:`pandas.DataFrame` with
def __init__(self): super(PIDController, self).__init__( unique_word="thermal_power_allocator_pid", ) def plot_controller(self, title="", width=None, height=None, ax=None): """Plot a summary of the controller data :param ax: Axis instance :type ax: :mod:`matplotlib.Axis` :param title: The title of the plot :type title: str :param width: The width of the plot :type width: int :param height: The height of the plot :type int: int """ title = normalize_title("PID", title) if not ax: ax = pre_plot_setup(width, height) self.data_frame[["output", "p", "i", "d"]].plot(ax=ax) post_plot_setup(ax, title=title) Run.register_class(PIDController, "thermal")