diff options
author | Javi Merino <javi.merino@arm.com> | 2015-04-22 17:07:42 +0100 |
---|---|---|
committer | Javi Merino <javi.merino@arm.com> | 2015-08-12 16:44:08 +0100 |
commit | 766ed3fea6b82594427892ecca722ef1acad72ea (patch) | |
tree | 9db1dbc5650ecd9dfad1751aa56659c065118eb9 | |
parent | 2cfd1e8efc013d4453147a1a284f164c0248321d (diff) | |
download | trappy-766ed3fea6b82594427892ecca722ef1acad72ea.tar.gz |
devfreq_power: add a module that collects data for devfreq cooling devices
Change-Id: I2a7fdcb6b3e995d410e48085a1e0f66b22792fea
Signed-off-by: Javi Merino <javi.merino@arm.com>
-rw-r--r-- | cr2/devfreq_power.py | 69 | ||||
-rw-r--r-- | tests/test_devfreq.py | 45 |
2 files changed, 114 insertions, 0 deletions
diff --git a/cr2/devfreq_power.py b/cr2/devfreq_power.py new file mode 100644 index 0000000..e09bbd6 --- /dev/null +++ b/cr2/devfreq_power.py @@ -0,0 +1,69 @@ +# $Copyright: +# ---------------------------------------------------------------- +# This confidential and proprietary software may be used only as +# authorised by a licensing agreement from ARM Limited +# (C) COPYRIGHT 2015 ARM Limited +# ALL RIGHTS RESERVED +# The entire notice above must be reproduced on all authorised +# copies and copies may only be made to the extent permitted +# by a licensing agreement from ARM Limited. +# ---------------------------------------------------------------- +# File: devfreq_power.py +# ---------------------------------------------------------------- +# $ +# + +"""Process the output of the devfreq_cooling devices in the current +directory's trace.dat""" + +from cr2.base import Base +from cr2.run import Run + + +class DevfreqInPower(Base): + """Process de devfreq cooling device data regarding get_power in an +ftrace dump""" + + name = "devfreq_in_power" + + def __init__(self): + super(DevfreqInPower, self).__init__( + unique_word="thermal_power_devfreq_get_power:", + ) + + def get_all_freqs(self): + """Return a pandas.Series with the frequencies for the devfreq device + + The format should be the same as the one for + CpuInPower().get_all_freqs(). Frequencies are in MHz. + + """ + + return 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" + + def __init__(self): + super(DevfreqOutPower, self).__init__( + unique_word="thermal_power_devfreq_limit:", + ) + + def get_all_freqs(self): + """Return a pandas.Series with the output frequencies for the devfreq +device + + The format should be the same that that of + CpuOutPower().get_all_freqs(). The frequencies are in MHz. + + """ + + return self.data_frame["freq"] / 1000000 + +Run.register_class(DevfreqOutPower, "thermal") diff --git a/tests/test_devfreq.py b/tests/test_devfreq.py new file mode 100644 index 0000000..b58c6d3 --- /dev/null +++ b/tests/test_devfreq.py @@ -0,0 +1,45 @@ +# $Copyright: +# ---------------------------------------------------------------- +# This confidential and proprietary software may be used only as +# authorised by a licensing agreement from ARM Limited +# (C) COPYRIGHT 2015 ARM Limited +# ALL RIGHTS RESERVED +# The entire notice above must be reproduced on all authorised +# copies and copies may only be made to the extent permitted +# by a licensing agreement from ARM Limited. +# ---------------------------------------------------------------- +# File: test_devfreq.py +# ---------------------------------------------------------------- +# $ +# +import cr2 +from test_thermal import BaseTestThermal + +class TestDevfreqPower(BaseTestThermal): + """Tests for the DevfreqInPower and DevfreqOutPower classes""" + + def test_devfreq_inp_dataframe(self): + """Test that DevfreqInPower creates proper data frames""" + devfreq_in_power = cr2.Run().devfreq_in_power + + self.assertTrue("freq" in devfreq_in_power.data_frame.columns) + + def test_devfreq_outp_dataframe(self): + """Test that DevfreqOutPower creates proper data frames""" + devfreq_out_power = cr2.Run().devfreq_out_power + + self.assertTrue("freq" in devfreq_out_power.data_frame.columns) + + def test_get_inp_all_freqs(self): + """Test that DevfreqInPower get_all_freqs() work""" + + all_freqs = cr2.Run().devfreq_in_power.get_all_freqs() + + self.assertEquals(all_freqs.iloc[0], 525) + + def test_get_outp_all_freqs(self): + """Test that DevfreqOutPower get_all_freqs() work""" + + all_freqs = cr2.Run().devfreq_out_power.get_all_freqs() + + self.assertEquals(all_freqs.iloc[0], 525) |