devfreq_power.py revision dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfe
1aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino#    Copyright 2015-2015 ARM Limited
2766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino#
3aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# Licensed under the Apache License, Version 2.0 (the "License");
4aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# you may not use this file except in compliance with the License.
5aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# You may obtain a copy of the License at
6aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino#
7aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino#     http://www.apache.org/licenses/LICENSE-2.0
8aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino#
9aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# Unless required by applicable law or agreed to in writing, software
10aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# distributed under the License is distributed on an "AS IS" BASIS,
11aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# See the License for the specific language governing permissions and
13aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino# limitations under the License.
14aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino#
15aace7c0732cac769f1ffe95a89591b6217fa9447Javi Merino
16766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
17766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino"""Process the output of the devfreq_cooling devices in the current
18766ed3fea6b82594427892ecca722ef1acad72eaJavi Merinodirectory's trace.dat"""
19766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
209c9867d383799ae84367396fd1dd8e471c0fbd28Javi Merinoimport pandas as pd
219c9867d383799ae84367396fd1dd8e471c0fbd28Javi Merino
22435457c8af9d69383ba45e0bd7da022d967a8deaJavi Merinofrom trappy.base import Base
23435457c8af9d69383ba45e0bd7da022d967a8deaJavi Merinofrom trappy.run import Run
24766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
25766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
26766ed3fea6b82594427892ecca722ef1acad72eaJavi Merinoclass DevfreqInPower(Base):
27766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    """Process de devfreq cooling device data regarding get_power in an
2895985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar SinghFTrace dump"""
29766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
30766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    name = "devfreq_in_power"
3195985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh    """The name of the :mod:`pandas.DataFrame` member that will be created in a
3295985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh    :mod:`trappy.run.Run` object"""
33766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
34dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino    unique_word="thermal_power_devfreq_get_power:"
35dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino    """The event name in the trace"""
36dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino
37766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    def __init__(self):
38dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino        super(DevfreqInPower, self).__init__(unique_word=self.unique_word)
39766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
40766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    def get_all_freqs(self):
4195985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        """Return a :mod:`pandas.DataFrame` with
4295985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        the frequencies for the devfreq device
43766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
44766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino        The format should be the same as the one for
4595985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        :code:`CpuInPower().get_all_freqs()`.
46766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
4795985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        .. note:: Frequencies are in MHz.
48766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino        """
49766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
509c9867d383799ae84367396fd1dd8e471c0fbd28Javi Merino        return pd.DataFrame(self.data_frame["freq"] / 1000000)
51766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
52766ed3fea6b82594427892ecca722ef1acad72eaJavi MerinoRun.register_class(DevfreqInPower, "thermal")
53766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
54766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
55766ed3fea6b82594427892ecca722ef1acad72eaJavi Merinoclass DevfreqOutPower(Base):
56766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    """Process de devfreq cooling device data regarding power2state in an
57766ed3fea6b82594427892ecca722ef1acad72eaJavi Merinoftrace dump"""
58766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
59766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    name = "devfreq_out_power"
6095985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh    """The name of the :mod:`pandas.DataFrame` member that will be created in a
6195985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh    :mod:`trappy.run.Run` object"""
62766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
63dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino    unique_word="thermal_power_devfreq_limit:"
64dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino    """The event name in the trace"""
65dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino
66766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    def __init__(self):
67dc9626d43b054c17e948aaaa7aa65a5e8ffe0cfeJavi Merino        super(DevfreqOutPower, self).__init__(unique_word=self.unique_word)
68766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
69766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino    def get_all_freqs(self):
7095985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        """Return a :mod:`pandas.DataFrame` with
7195985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        the output frequencies for the devfreq device
72766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
7395985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        The format should be the same as the one for
7495985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        :code:`CpuOutPower().get_all_freqs()`.
75766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
7695985b5125b3e96b8cd87460cc375600a8de49eaKapileshwar Singh        .. note:: Frequencies are in MHz.
77766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino        """
78766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
799c9867d383799ae84367396fd1dd8e471c0fbd28Javi Merino        return pd.DataFrame(self.data_frame["freq"] / 1000000)
80766ed3fea6b82594427892ecca722ef1acad72eaJavi Merino
81766ed3fea6b82594427892ecca722ef1acad72eaJavi MerinoRun.register_class(DevfreqOutPower, "thermal")
82