def test_plot_inout_power(self): """Test plot_inout_power() Can't check that the graph is ok, so just see that the method doesn't blow up""" trappy.Run().thermal_governor.plot_inout_power() trappy.Run().thermal_governor.plot_inout_power(title="Antutu") matplotlib.pyplot.close('all')
def test_plot_filter(self): """Tests LinePlot with no Pivot with filters""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot([run1, run2], [trappy.cpu_power.CpuOutPower], column=["power"], filters={"cdev_state": [1]}) l.view(test=True)
def test_plot_multi_run(self): """Tests LinePlot with no Pivot multi runs""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot([run1, run2], trappy.thermal.Thermal, column="temp") l.view(test=True)
def test_plot_temperature(self): """Test that plot_utils.plot_temperature() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_temperature(runs, ylim="default") matplotlib.pyplot.close('all')
def test_plot_output_power(self): """plot_utils.plot_output_power() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_output_power(runs, self.actor_order, width=20) matplotlib.pyplot.close('all')
def test_plot_allfreqs(self): """Test that plot_utils.plot_allfreqs() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_allfreqs(runs, self.map_label, width=20) matplotlib.pyplot.close('all')
def test_plot_controller(self): """plot_utils.plot_controller() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_controller(runs, height=5) matplotlib.pyplot.close('all')
def test_plot_multi(self): """Tests LinePlot with no Pivot multi attrs""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot( [run1, run2], [trappy.thermal.Thermal, trappy.thermal.ThermalGovernor], column=["temp", "power_range"]) l.view(test=True)
def test_plot_load(self): """Test that plot_utils.plot_load() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_load(runs, self.map_label, height=5) matplotlib.pyplot.close('all')
def test_plot_temperature_hist(self): """plot_utils.plot_temperature_hist() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_temperature_hist(runs) matplotlib.pyplot.close('all')
def test_plot_multi_run_pivot(self): """Tests LinePlot with Pivot multi runs""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot([run1, run2], trappy.cpu_power.CpuOutPower, column="power", pivot="cpus") l.view(test=True)
def test_plot_freq_hists(self): """plot_utils.plot_freq_hists() doesn't bomb""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") runs = [run1, run2] plot_utils.plot_freq_hists(runs, self.map_label) matplotlib.pyplot.close('all')
def test_plot_multi_pivot_filter(self): """Tests LinePlot with Pivot and filters""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot(run1, trappy.cpu_power.CpuInPower, column=["dynamic_power", "load1"], filters={"cdev_state": [1, 0]}, pivot="cpus") l.view(test=True)
def test_plot_multi_pivot(self): """Tests LinePlot with Pivot with multi attrs""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot( [run1, run2], [trappy.cpu_power.CpuInPower, trappy.cpu_power.CpuOutPower], column=["dynamic_power", "power"], pivot="cpus") l.view(test=True)
def test_plot_savefig(self): """Tests plotter: savefig""" run1 = trappy.Run(name="first") run2 = trappy.Run(name="second") l = trappy.LinePlot(run1, trappy.cpu_power.CpuInPower, column=["dynamic_power", "load1"], filters={"cdev_state": [1, 0]}, pivot="cpus") png_file = tempfile.mktemp(dir="/tmp", suffix=".png") l.savefig(png_file) self.assertTrue(os.path.isfile(png_file)) os.remove(png_file)
def test_plotter_triplicates(self): """Test that plotter handles triplicates fine""" with open("trace.txt", "w") as fout: fout.write("""version = 6 cpus=6 rcuos/2-22 [001] 0000.018510: sched_load_avg_sg: cpus=00000001 load=0 utilization=0 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000002 load=1 utilization=1 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2 rcuos/2-22 [001] 6550.018612: sched_load_avg_sg: cpus=00000001 load=2 utilization=3 rcuos/2-22 [001] 6550.018624: sched_load_avg_sg: cpus=00000002 load=1 utilization=4 rcuos/2-22 [001] 6550.018625: sched_load_avg_sg: cpus=00000002 load=2 utilization=5 rcuos/2-22 [001] 6550.018626: sched_load_avg_sg: cpus=00000002 load=3 utilization=6 rcuos/2-22 [001] 6550.018627: sched_load_avg_sg: cpus=00000002 load=1 utilization=7 rcuos/2-22 [001] 6550.018628: sched_load_avg_sg: cpus=00000004 load=2 utilization=8\n""" ) fout.close() run1 = trappy.Run(name="first") l = trappy.LinePlot(run1, trappy.sched.SchedLoadAvgSchedGroup, column=['utilization'], filters={"load": [1, 2]}, pivot="cpus", marker='o', linestyle='none', per_line=3) l.view(test=True)
def test_run_has_all_classes_scope_all(self): """The Run() class has members for all classes with scope=all""" run = trappy.Run(scope="all") for attr in run.class_definitions.iterkeys(): self.assertTrue(hasattr(run, attr))
def test_plot_normalized_load(self): """Test that plot_normalized_load() doesn't explode""" run = trappy.Run() _, ax = matplotlib.pyplot.subplots() run.plot_normalized_load(self.map_label, ax=ax)
def test_empty_trace_txt(self): """Test that empty objects are created with empty trace file""" run = trappy.Run() for attr in run.sched_classes.iterkeys(): self.assertTrue(len(getattr(run, attr).data_frame) == 0)
def plot_trace(trace_dir, execnames=None, pids=None): """Creates a kernelshark like plot of the trace file :param trace_dir: The location of the trace file :type trace_dir: str :param pids: List of execnames to be filtered. If not specified all execnames will be plotted :type execnames: list, str :param pids: List of pids to be filtered. If not specified all pids will be plotted :type pids: list, str """ if not IPythonConf.check_ipython(): raise RuntimeError("plot_trace needs ipython environment") run = trappy.Run(trace_dir) data, procs, domain = Utils.get_trace_event_data(run, execnames, pids) trace_graph = EventPlot.EventPlot(data, procs, domain, lane_prefix="CPU :", num_lanes=int(run._cpus)) trace_graph.view()
def test_plot_freq_hists_single_run(self): """plot_utils.plot_freq_hists() works with a single run""" run = trappy.Run() plot_utils.plot_freq_hists([run], self.map_label) matplotlib.pyplot.close('all')
def test_both_txt_files(self): """test raw parsing for txt files""" self.assertFalse(os.path.isfile("trace.dat")) run = trappy.Run() self.assertTrue(hasattr(run, "sched_switch")) self.assertTrue(len(run.sched_switch.data_frame) > 0)
def test_plot_load(self): """Test that plot_load() doesn't explode""" run = trappy.Run() run.plot_load(self.map_label, title="Util") _, ax = matplotlib.pyplot.subplots() run.plot_load(self.map_label, ax=ax)
def test_get_dataframe(self): dfr = trappy.Run().thermal_governor.data_frame self.assertTrue(len(dfr) > 0) self.assertEquals(dfr["current_temperature"].iloc[0], 68775) self.assertTrue("total_granted_power" in dfr.columns) self.assertFalse("time" in dfr.columns)
def test_raw_dat(self): """Tests an event that relies on raw parsing""" run = trappy.Run() self.assertTrue(hasattr(run, "sched_switch")) self.assertTrue(len(run.sched_switch.data_frame) > 0) self.assertTrue("prev_comm" in run.sched_switch.data_frame.columns)
def test_cpuinpower_get_all_freqs(self): """Test CpuInPower.get_all_freqs()""" dfr = trappy.Run().cpu_in_power.get_all_freqs(self.map_label) self.assertEquals(dfr["A57"].iloc[0], 1100) self.assertEquals(dfr["A53"].iloc[1], 850) self.assertEquals(dfr["A57"].iloc[5], 1100)
def test_run_has_all_classes(self): """The Run() class has members for all classes""" run = trappy.Run() for attr in run.class_definitions.iterkeys(): self.assertTrue(hasattr(run, attr))
def test_get_dataframe(self): """TestBase: Thermal.data_frame["thermal_zone"] exists and it contains a known value""" dfr = trappy.Run().thermal.data_frame self.assertTrue("thermal_zone" in dfr.columns) self.assertEquals(dfr["temp"].iloc[0], 68786)
def test_get_runtime(self): r = trappy.Run() # The ls process is process we are # testing against with pre calculated # values process = "ls" # Complete duration expected_time = 0.0034740000264719129 s = SchedAssert(r, self.topology, execname=process) self.assertAlmostEqual(s.getRuntime(), expected_time, places=9) self.assertAlmostEqual(s.getRuntime(), expected_time, places=9) # Non Interrupted Window window = (0.0034, 0.003525) expected_time = 0.000125 self.assertAlmostEqual(s.getRuntime(window=window), expected_time, places=9) # Interrupted Window window = (0.0030, 0.0032) expected_time = 0.000166 self.assertAlmostEqual(s.getRuntime(window=window), expected_time, places=9) # A window with multiple interruptions window = (0.0027, 0.0036) expected_time = 0.000817 self.assertAlmostEqual(s.getRuntime(window=window), expected_time, places=9)
def test_do_raw_txt_if_not_there(self): """Create trace.raw.txt if it's not there""" self.assertFalse(os.path.isfile("trace.raw.txt")) trappy.Run() self.assert_thermal_in_trace("trace.raw.txt")