In [1]:
import sys,os
import tempfile
import shutil
sys.path.append("..")
%matplotlib inline
import trappy
trace_thermal = "./trace.txt"
trace_sched = "../tests/trace_sched.txt"
TEMP_BASE = "/tmp"
In [2]:
def setup_thermal():
tDir = tempfile.mkdtemp(dir="/tmp", prefix="trappy_doc", suffix = ".tempDir")
shutil.copyfile(trace_thermal, os.path.join(tDir, "trace.txt"))
return tDir
def setup_sched():
tDir = tempfile.mkdtemp(dir="/tmp", prefix="trappy_doc", suffix = ".tempDir")
shutil.copyfile(trace_sched, os.path.join(tDir, "trace.txt"))
return tDir
In [3]:
temp_thermal_location = setup_thermal()
trace1 = trappy.FTrace(temp_thermal_location)
trace2 = trappy.FTrace(temp_thermal_location)
trace2.thermal.data_frame["temp"] = trace1.thermal.data_frame["temp"] * 2
trace2.cpu_out_power.data_frame["power"] = trace1.cpu_out_power.data_frame["power"] * 2
A signal is a string which represents a combination of a TRAPpy event and a column. The format of the signal is, "event_name:column". e.g, thermal:temp.
The Plotter API can accept either a list of signals as an input or a combination of templates and columns. Here is an example on how to use signals:
In [4]:
l = trappy.LinePlot(trace1, signals=["thermal:temp"])
l.view()
In [5]:
l = trappy.LinePlot(trace1, trappy.thermal.Thermal, column="temp")
l.view()
In [6]:
l = trappy.LinePlot([trace1, trace2], trappy.thermal.Thermal, column="temp")
l.view()
In [7]:
l = trappy.LinePlot([trace1, trace2], [trappy.thermal.Thermal,trappy.thermal.ThermalGovernor], column=["temp", "power_range"])
l.view()
In [8]:
l = trappy.LinePlot([trace1, trace2], [trappy.cpu_power.CpuOutPower], column="power", filters={"cdev_state": [0]})
l.view()
In [9]:
l = trappy.LinePlot(trace1, trappy.thermal.Thermal, column="temp", pivot="thermal_zone")
l.view()
In [10]:
l = trappy.LinePlot([trace1, trace2], trappy.cpu_power.CpuOutPower, column="power", pivot="cpus")
l.view()
A dictionary at that maps pivot values into possibly useful labels can be provided
In [11]:
map_label = {
"00000000,00000006" : "A57",
"00000000,00000039" : "A53",
}
l = trappy.LinePlot([trace1, trace2], trappy.cpu_power.CpuOutPower, column="power", pivot="cpus", map_label=map_label)
l.view()
In [12]:
l = trappy.LinePlot([trace1, trace2],
[trappy.cpu_power.CpuInPower, trappy.cpu_power.CpuOutPower],
column=["dynamic_power", "power"],
pivot="cpus")
l.view()
In [13]:
l = trappy.LinePlot(trace1, trappy.cpu_power.CpuInPower, column=["dynamic_power", "load1"],
filters={"cdev_state": [1, 0]}, pivot="cpus")
l.view()
Here is the same plot using signals:
In [14]:
l = trappy.LinePlot(trace1, signals=["cpu_in_power:dynamic_power", "cpu_in_power:load1"],
filters={"cdev_state": [1, 0]}, pivot="cpus")
l.view()
The permute parameter allows to plot all the permutations of the specified traces with the specified columns. Each figure will plot the values of each column for those traces. Hence, with N traces and M columns, you will get M figures each displaying N traces.
In [15]:
l = trappy.LinePlot([trace1, trace2], trappy.thermal.Thermal, column=["temp", "temp_prev"], permute=True)
l.view()