1#    Copyright 2015-2017 ARM Limited
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16
17"""Process the output of the devfreq_cooling devices in the current
18directory's trace.dat"""
19
20import pandas as pd
21
22from trappy.base import Base
23from trappy.dynamic import register_ftrace_parser
24
25
26class DevfreqInPower(Base):
27    """Process de devfreq cooling device data regarding get_power in an
28FTrace dump"""
29
30    name = "devfreq_in_power"
31    """The name of the :mod:`pandas.DataFrame` member that will be created in a
32    :mod:`trappy.ftrace.FTrace` object"""
33
34    unique_word="thermal_power_devfreq_get_power:"
35    """The event name in the trace"""
36
37    def get_all_freqs(self):
38        """Return a :mod:`pandas.DataFrame` with
39        the frequencies for the devfreq device
40
41        The format should be the same as the one for
42        :code:`CpuInPower().get_all_freqs()`.
43
44        .. note:: Frequencies are in MHz.
45        """
46
47        return pd.DataFrame(self.data_frame["freq"] / 1000000)
48
49register_ftrace_parser(DevfreqInPower, "thermal")
50
51
52class DevfreqOutPower(Base):
53    """Process de devfreq cooling device data regarding power2state in an
54ftrace dump"""
55
56    name = "devfreq_out_power"
57    """The name of the :mod:`pandas.DataFrame` member that will be created in a
58    :mod:`trappy.ftrace.FTrace` object"""
59
60    unique_word="thermal_power_devfreq_limit:"
61    """The event name in the trace"""
62
63    def get_all_freqs(self):
64        """Return a :mod:`pandas.DataFrame` with
65        the output frequencies for the devfreq device
66
67        The format should be the same as the one for
68        :code:`CpuOutPower().get_all_freqs()`.
69
70        .. note:: Frequencies are in MHz.
71        """
72
73        return pd.DataFrame(self.data_frame["freq"] / 1000000)
74
75register_ftrace_parser(DevfreqOutPower, "thermal")
76