diff options
author | Javi Merino <javi.merino@arm.com> | 2016-01-05 14:47:07 +0000 |
---|---|---|
committer | Javi Merino <javi.merino@arm.com> | 2016-01-05 19:05:49 +0000 |
commit | 94d89c1b3c8aa29038731aade64b7a840622690f (patch) | |
tree | 241587293722bc23c986e316b1e30fd45d6f137b | |
parent | ab94dac062ed58f03b1728a2857fa1563ed1e900 (diff) | |
download | trappy-94d89c1b3c8aa29038731aade64b7a840622690f.tar.gz |
plot_utils: fix plot_allfreqs() for one actor
When the system has only one actor and you use trappy.summary_plots() or
trappy.compare_runs() you get:
Traceback (most recent call last):
File "trappy/tests/test_trappy.py", line 127, in test_summary_plots_one_actor
trappy.summary_plots(self.actor_order, map_label)
File "trappy/trappy/compare_runs.py", line 96, in summary_plots
return compare_runs(actor_order, map_label, [(title, path)], **kwords)
File "trappy/trappy/compare_runs.py", line 78, in compare_runs
trappy.plot_utils.plot_allfreqs(run_data, map_label, **kwords)
File "trappy/trappy/plot_utils.py", line 209, in plot_allfreqs
run.plot_allfreqs(map_label, ax=ax)
File "trappy/trappy/ftrace.py", line 531, in plot_allfreqs
for this_ax, (label, dfr) in zip(ax, all_freqs):
TypeError: zip argument #1 must support iteration
This is because plt.subplots() returns just the axis if ncols and nrows
are both 1, a 1D array if either ncols or nrows is 1 and a 2D array
otherwise. plot_utils.plot_all_freqs() copes with ncols being 1 but not
with nrows being 1. The latter happens when you use summary_plots() or
compare_runs() and there is only one actor.
Fix it so that axis is always a 2D array: the first index is the run and
the second the actor.
-rw-r--r-- | tests/test_plot_utils.py | 15 | ||||
-rw-r--r-- | tests/test_trappy.py | 19 | ||||
-rw-r--r-- | trappy/plot_utils.py | 7 |
3 files changed, 40 insertions, 1 deletions
diff --git a/tests/test_plot_utils.py b/tests/test_plot_utils.py index d5a6def..e912762 100644 --- a/tests/test_plot_utils.py +++ b/tests/test_plot_utils.py @@ -181,6 +181,21 @@ class TestPlotUtilsNeedTrace(BaseTestThermal): plot_utils.plot_allfreqs([trace], self.map_label) matplotlib.pyplot.close('all') + def test_plot_allfreqs_one_actor(self): + """plot_utils.plot_allfreqs work when there is only one actor""" + + in_data = """ kworker/4:1-397 [004] 720.741349: thermal_power_cpu_get: cpus=00000000,00000006 freq=1400000 raw_cpu_power=189 load={23, 12} power=14 + kworker/4:1-397 [004] 720.741349: thermal_power_cpu_limit: cpus=00000000,00000006 freq=1400000 cdev_state=1 power=14""" + + with open("trace.txt", "w") as fout: + fout.write(in_data) + + traces = [trappy.FTrace(name="first"), trappy.FTrace(name="second")] + map_label = {"00000000,00000006": "A57"} + + plot_utils.plot_allfreqs(traces, map_label) + matplotlib.pyplot.close("all") + def test_plot_controller(self): """plot_utils.plot_controller() doesn't bomb""" diff --git a/tests/test_trappy.py b/tests/test_trappy.py index 53e0afe..d66b96d 100644 --- a/tests/test_trappy.py +++ b/tests/test_trappy.py @@ -107,6 +107,25 @@ class TestTrappy(BaseTestThermal): trappy.summary_plots(self.actor_order, self.map_label) matplotlib.pyplot.close('all') + def test_summary_plots_one_actor(self): + """summary_plots() works if there is only one actor""" + + # Strip out devfreq and little traces + trace_out = "" + with open("trace.txt") as fin: + for line in fin: + if ("thermal_power_devfreq_get_power:" not in line) and \ + ("thermal_power_devfreq_limit:" not in line) and \ + ("thermal_power_cpu_get_power: cpus=00000000,00000039" not in line) and \ + ("thermal_power_cpu_limit: cpus=00000000,00000039" not in line): + trace_out += line + + with open("trace.txt", "w") as fout: + fout.write(trace_out) + + map_label = {"00000000,00000006": "A57"} + trappy.summary_plots(self.actor_order, map_label) + matplotlib.pyplot.close('all') def test_compare_runs(self): """Basic compare_runs() functionality""" diff --git a/trappy/plot_utils.py b/trappy/plot_utils.py index c7054ab..4fa0323 100644 --- a/trappy/plot_utils.py +++ b/trappy/plot_utils.py @@ -201,7 +201,12 @@ def plot_allfreqs(runs, map_label, width=None, height=None): ncols=num_runs) if num_runs == 1: - axis = [axis] + if nrows == 1: + axis = [[axis]] + else: + axis = [axis] + elif nrows == 1: + axis = [[ax] for ax in axis] else: axis = zip(*axis) |