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 17import trappy.ftrace 18 19def compare_runs(actor_order, map_label, runs, **kwords): 20 """A side by side comparison of multiple runs 21 22 Plots include temperature, utilization, frequencies, PID 23 controller and power. 24 25 :param actor_order: An array showing the order in which the actors 26 were registered. The array values are the labels that 27 will be used in the input and output power plots. 28 29 For Example: 30 :: 31 32 ["GPU", "A15", "A7"] 33 34 :param map_label: A dict that matches cpumasks (as found in the 35 trace) with their proper name. This "proper name" will be used as 36 a label for the load and allfreqs plots. It's recommended that 37 the names of the cpus matches those in actor_order. 38 39 For Example: 40 :: 41 42 {"0000000f": "A7", "000000f0": "A15"} 43 44 :param runs: An array of tuples consisting of a name and the path to 45 the directory where the trace.dat is. 46 47 For example: 48 :: 49 50 [("experiment1", "wa_output/antutu_antutu_1"), 51 ("known good", "good/antutu_antutu_1")] 52 53 :param tz_id: thermal zone id as it appears in the id field of the 54 thermal_temperature trace event 55 56 :type actor_order: list 57 :type map_label: dict 58 :type runs: list 59 :type tz_id: int 60 61 """ 62 import trappy.plot_utils 63 import trappy.wa 64 65 if not isinstance(actor_order, list): 66 raise TypeError("actor_order has to be an array") 67 68 if not isinstance(map_label, dict): 69 raise TypeError("map_label has to be a dict") 70 71 if "width" not in kwords: 72 kwords["width"] = 20 73 if "height" not in kwords: 74 kwords["height"] = 5 75 76 run_data = [] 77 for name, path in runs: 78 run_data.append(trappy.FTrace(name=name, path=path, scope="thermal")) 79 trappy.wa.SysfsExtractor(path).pretty_print_in_ipython() 80 81 trappy.plot_utils.plot_temperature(run_data, **kwords) 82 if "tz_id" in kwords: 83 del kwords["tz_id"] 84 85 try: 86 trappy.plot_utils.plot_load(run_data, map_label, **kwords) 87 except IndexError: 88 raise ValueError("No power allocator traces found. Was IPA active (temp above switch on temperature) and FTrace configured to collect all thermal events?") 89 trappy.plot_utils.plot_allfreqs(run_data, map_label, **kwords) 90 trappy.plot_utils.plot_controller(run_data, **kwords) 91 trappy.plot_utils.plot_input_power(run_data, actor_order, **kwords) 92 trappy.plot_utils.plot_output_power(run_data, actor_order, **kwords) 93 trappy.plot_utils.plot_freq_hists(run_data, map_label) 94 trappy.plot_utils.plot_temperature_hist(run_data) 95 96def summary_plots(actor_order, map_label, **kwords): 97 """A summary of plots for a given run 98 99 .. warning:: 100 101 This is a wrapper around compare_runs(). Use that instead. 102 """ 103 104 path = kwords.pop("path", ".") 105 title = kwords.pop("title", "") 106 107 return compare_runs(actor_order, map_label, [(title, path)], **kwords) 108