jitter.py 1.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (16,9)
plt.rcParams.update({'figure.autolayout': True})

from xlap.analyse.common import get_outlier_treshold, extract_durations
from xlap.analyse import box

def _dn(x):
    return x + "Time"

def _filter(x, durations, source):
    return durations[x]["Source"] == source

def _jitter_causes(df,title="JitterCause.pdf"):
    stats = df["EndToEndTime"].describe()
    tresh = get_outlier_treshold(stats)
    outliers = df[df["EndToEndTime"] > tresh]

    reasons = ["SendTime",
               "PrrtTransmitTime",
               "LinkTransmitTime",
               "SubmitTime",
               "SenderIPCTime",
               "SenderEnqueuedTime",
               #"EncodingTime",
               "EnqueueTime",
               "DecodingTime",
               "HandlePacketTime",
               "ReceiverIPCTime",
               "FeedbackTime"]

    df_reasons = pd.DataFrame(index=outliers.index)

    for r in reasons:
        r_tresh = get_outlier_treshold(df[r].describe())
        df_reasons[r] = 0
        df_reasons[r] = outliers[outliers[r] > r_tresh].notnull()


    df_sum = df_reasons.sum().sort_values(ascending=False)
    ax = df_sum.plot.bar(x="Reason",y="Frequency",rot=45,grid=True,legend=False,color="black")
    fig=ax.get_figure()
    plt.ylabel("Frequency")
    ax.set_xticklabels(list(map(lambda x: x.get_text().replace("Time", ""), ax.get_xticklabels())))
    fig.set_size_inches(8, 3, forward=True)
    fig.savefig(title)
    print("Outliers:",len(outliers),";","Threshold[us]:",tresh)


def analyse(df_data, config, file_name=None):
    columns = extract_durations(config)

    df_box = df_data[columns]
    thresh = get_outlier_treshold(df_box["EndToEndTime"].describe())
    df_no = df_box[df_box["EndToEndTime"] <= thresh]
    box(df_no, file_name)
    print("No of non-outliers:",len(df_no))
    fig = plt.gcf()
    fig.canvas.set_window_title('Jitter Analysis')
    plt.show()
    _jitter_causes(df_box)