Commit c26ea990 authored by Andreas Schmidt's avatar Andreas Schmidt

Add a sample notebook. Refactor regression out.

parent 034268b7
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -112,10 +112,6 @@ durations:
Start: PrrtSendEnd
Stop: LinkTransmitStart
Source: sender
Encoding:
Start: PrrtEncodeStart
Stop: PrrtEncodeEnd
Source: sender
ReceiverIPC:
Start: PrrtReturnPackage
......
import math
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (16, 9)
......@@ -10,54 +10,21 @@ plt.rcParams.update({'figure.autolayout': True})
def trace(df, title, export=False):
fig, ax = plt.subplots(figsize=(8, 4.5))
plt.grid()
base = df["PrrtSendStart_T"]
sender_color = "#AAAAAA"
receiver_color = "#888888"
series = np.transpose(np.array([
["PrrtSendStart_T", "PrrtDeliver_T", "black", "EndToEnd"],
["PrrtSendStart_T", "LinkTransmitEnd_T", sender_color, "SenderTotal"],
["PrrtSendStart_T", "PrrtSendEnd_T", sender_color, "Send"],
["PrrtSendStart_T", "PrrtSubmitPackage_T", sender_color, "Submit"],
["PrrtSubmitPackage_T", "PrrtTransmitStart_T", sender_color, "SenderIPC"],
["PrrtSubmitPackage_T", "PrrtSendEnd_T", sender_color, "Enqueue"],
["PrrtSendEnd_T", "LinkTransmitStart_T", sender_color, "SenderEnqueued"],
["PrrtTransmitStart_T", "PrrtTransmitEnd_T", sender_color, "PrrtTransmit"],
["LinkTransmitStart_T", "LinkTransmitEnd_T", sender_color, "LinkTransmit"],
["LinkReceive_T", "PrrtDeliver_T", receiver_color, "ReceiverTotal"],
# ["DecodeStart_T", "DecodeEnd_T", receiver_color, "Decoding"],
["HandlePacketStart_T", "HandlePacketEnd_T", receiver_color, "HandlePacket"],
["PrrtReturnPackage_T", "PrrtReceivePackage_T", receiver_color, "ReceiverIPC"],
["SendFeedbackStart_T", "SendFeedbackEnd_T", receiver_color, "Feedback"],
]))
n = series.shape[1]
starts = df[series[0]] - base
ends = df[series[1]] - base
plt.hlines(range(n), starts, ends, series[2], linewidths=[5])
plt.xlabel("Time [us]")
fig.canvas.draw()
ax.set_yticklabels(series[3])
ax.yaxis.set_ticks(np.arange(0, n, 1))
if export:
plt.savefig(title)
plt.show()
def box(df_data, export=False, title=None):
ax = df_data.plot.box(vert=False, grid=True)
def box(data_frame, export=False, file_name=None):
"""
Display a boxplot for the durations contained in data_frame.
:param data_frame:
:param export:
:param file_name:
:return:
"""
ax = data_frame.plot.box(vert=False, grid=True)
fig = ax.get_figure()
ax.set_yticklabels(list(map(lambda x: x.get_text().replace("_D", ""), ax.get_yticklabels())))
plt.xlabel("Time [us]")
fig.set_size_inches(8, 4.5, forward=True)
if export and title is not None:
fig.savefig(title)
if export and file_name is not None:
fig.savefig(file_name)
def describe_table(df):
......@@ -87,7 +54,7 @@ def correlation(df_data, title="Correlation.pdf"):
i = 0
for column in columns:
ax = df_data.plot.scatter(ax=axes[i // cols, i % cols], y="EndToEndTime", x=column, grid=True, marker="+",
ax = df_data.plot.scatter(ax=axes[i // cols, i % cols], y="EndToEnd_D", x=column, grid=True, marker="+",
color="black")
ax.set_ylabel("EndToEnd [us]")
ax.margins(0.1, 0.1)
......
......@@ -18,7 +18,7 @@ def _filter(x, durations, source):
def extract_durations(config):
durations = config["durations"]
durations_send = [_dn(x) for x in durations if _filter(x, durations, "sender")]
durations_recv = [_dn(x) for x in durations if _filter(x, durations, "receiver")]
durations_send = [x for x in durations if _filter(x, durations, "sender")]
durations_recv = [x for x in durations if _filter(x, durations, "receiver")]
return ["EndToEndTime", "Sender_D"] + durations_send + ["Receiver_D"] + durations_recv
return ["EndToEnd", "Sender"] + durations_send + ["Receiver"] + durations_recv
......@@ -5,9 +5,9 @@ from xlap.analyse import box
def jitter_causes(df, durations, export=False, file_name=None):
stats = df["EndToEndTime"].describe()
stats = df["EndToEnd_D"].describe()
threshold = get_outlier_threshold(stats)
outliers = df[df["EndToEndTime"] > threshold]
outliers = df[df["EndToEnd_D"] > threshold]
reasons = [d + "_D" for d in durations.keys()]
......@@ -33,8 +33,8 @@ def trace_jitter(data_frame, export=False, file_name=None):
"""
Displays (and saves) a stacked boxplot of durations.
"""
thresh = get_outlier_threshold(data_frame["EndToEndTime"].describe())
df_no_outliers = data_frame[data_frame["EndToEndTime"] <= thresh]
thresh = get_outlier_threshold(data_frame["EndToEnd_D"].describe())
df_no_outliers = data_frame[data_frame["EndToEnd_D"] <= thresh]
box(df_no_outliers, export, file_name)
print("{} / {} are no outliers.".format(len(df_no_outliers), len(data_frame)))
fig = plt.gcf()
......@@ -45,4 +45,4 @@ def trace_jitter(data_frame, export=False, file_name=None):
def prep(df, config):
plt.rcParams["figure.figsize"] = (16, 9)
plt.rcParams.update({'figure.autolayout': True})
return df[extract_durations(config)]
return df[[x + "_D" for x in extract_durations(config)]]
import numpy as np
import matplotlib.pyplot as plt
from xlap.analyse.common import extract_durations
def _create_line(config):
tr = config["time_reference"]
color = {
"sender": "#AAAAAA",
"receiver": "#888888",
"e2e": "black"
}
def _creator(duration_name):
if duration_name == "EndToEnd":
return [tr["sender"]["Start"] + "_T", tr["receiver"]["Stop"] + "_T", color["e2e"], "EndToEnd"]
elif duration_name == "Sender":
return [tr["sender"]["Start"] + "_T", tr["sender"]["Stop"] + "_T", color["sender"], "Sender"]
elif duration_name == "Receiver":
return [tr["receiver"]["Start"] + "_T", tr["receiver"]["Stop"] + "_T", color["receiver"], "Receiver"]
else:
duration = config["durations"][duration_name]
return [duration["Start"] + "_T", duration["Stop"] + "_T", color[duration["Source"]], duration_name]
return _creator
def trace(data_frame, config, export=False, file_name="TraceJitter.pdf"):
"""
:param data_frame:
:param config:
:param export:
:param file_name:
:return:
"""
fig, ax = plt.subplots(figsize=(8, 4.5))
plt.grid()
line_creator = _create_line(config)
durations = [line_creator(x) for x in extract_durations(config)]
series = np.transpose(np.array(durations))
n = series.shape[1]
# Starts and Ends
tr = config["time_reference"]
base = data_frame[tr["sender"]["Start"] + "_T"]
starts = data_frame[series[0]] - base
ends = data_frame[series[1]] - base
plt.hlines(range(n), starts, ends, series[2], linewidths=[5])
plt.xlabel("Time [us]")
fig.canvas.draw()
ax.set_yticklabels(series[3])
ax.yaxis.set_ticks(np.arange(0, n, 1))
if export:
plt.savefig(file_name)
plt.show()
......@@ -76,7 +76,7 @@ def evaluate(sender_file, receiver_file, config, kind=0):
df[name + "Cycles"] = diff
df[name + "_D"] = diff * df[duration["Source"].capitalize() + "Cycle_D"]
df["EndToEndTime"] = df["Sender_D"] + df["Receiver_D"]
df["EndToEnd_D"] = df["Sender_D"] + df["Receiver_D"]
return df
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment