Commit a96c866f authored by Stefan Reif's avatar Stefan Reif
Browse files

Differential timing analysis

parent 7b509e64
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -39,14 +39,14 @@ stamps:
        Source: sender
        Thread: app_send
        Type: time
    PrrtSendPacketStart:
        Source: sender
        Thread: trans_send
        Type: none
    PrrtSendPacketEnd:
        Source: sender
        Thread: trans_send
        Type: none
#    PrrtSendPacketStart:
#        Source: sender
#        Thread: trans_send
#        Type: none
#    PrrtSendPacketEnd:
#        Source: sender
#        Thread: trans_send
#        Type: none

    PrrtTransmitStart:
        Source: sender

xlap/analyse/diff.py

0 → 100644
+39 −0
Original line number Diff line number Diff line
import math
import numpy as np
from .util import cdf, extract_durations
from scipy import stats
import matplotlib.pyplot as plt
import xlap.analyse.latency as latency

confidence = 0.99

def remove_outliers(data):
    m = 2
    u = np.mean(data)
    s = np.std(data)
    filtered = [e for e in data if (u - 2 * s <= e and e <= u + 2 * s)]
    return filtered

def samples_are_different(sample1, sample2):
    # TODO: handle insufficient data. This case typically occurs when a duration is always zero.
    if 1 >= len(sample1) or 1 >= len(sample2) or 0 == np.std(sample1) or 0 == np.std(sample2):
        print("insufficient data")
        return 0
    a2, critical, pvalue = stats.anderson_ksamp([sample1, sample2])
    if a2 > critical[4]:
        return 1 # KS reject: samples are different
    else:
        return 0 # KS accept: samples are equal or similar

def duration_to_string(d):
    return str(d['Start']) + "->" + str(d['Stop'])

def analyse(df1, df2, config, export=False):
    for d in latency.get_durations(df1, config):
        data1 = df1[d['Stop']] - df1[d['Start']]
        data2 = df2[d['Stop']] - df2[d['Start']]
        if samples_are_different(remove_outliers(data1), remove_outliers(data2)) and samples_are_different(data1, data2):
            print(duration_to_string(d) + " has changed: "+str(np.mean(data1))+"+-"+str(np.std(data1))+" <-> "+str(np.mean(data2))+"+-"+str(np.std(data2))+" ")
        else:
            print(duration_to_string(d) + " has not changed significantly")
+26 −0
Original line number Diff line number Diff line
@@ -178,6 +178,32 @@ def _plot_critical_regions(hdb):
    plt.savefig("latency-criticality.pdf")
    plt.close()

def get_durations(df, config):
    hb = []

    events = [column for column in df.columns if column.endswith("_T")]

    for event1 in df[events]:
        for event2 in df[events]:
            if str(event1) == str(event2):
                continue
            if _happens_before(df, event1, event2, config):
                hb += [{'Start': str(event1), 'End': str(event2)}]

    hdb = []
    e2e = list(df['EndToEnd_D'])
    for event1 in df[events]:
        for event2 in df[events]:
            if str(event1) == str(event2):
                continue
            # if _locally_happens_directly_before(df, event1, event2, hb, config):
            if _happens_directly_before(df, event1, event2, hb):
                # compute the correlation between e2e latency and event1-event2 latency
                l3 = list(df[event2] - df[event1])

                hdb += [{'Start': str(event1), 'Stop': str(event2), 'Source': 'cfa'}]
    return hdb

def analyse(df, config):
    hb = []

+11 −0
Original line number Diff line number Diff line
@@ -3,10 +3,12 @@ import argparse
from xlap.parse import evaluate, parse_config
import xlap.analyse.jitter as jitter
import xlap.analyse.latency as latency
import xlap.analyse.diff as difference

tasks = {
    "jitter": None,
    "latency": None,
    "difference": None,
    "capture": None
}

@@ -45,6 +47,15 @@ def main():
            df_data = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)
            a = latency.analyse(df_data, config)
            print(a.corr.sort_values(ascending=False))
        elif command == "difference":
            df_data1 = evaluate("../prrt/out/s.csv", "../prrt/out/r.csv", config=config, kind=0)
            # sanity check:
            #df_data2 = evaluate("../prrt/out/s.csv", "../prrt/out/r.csv", config=config, kind=0)
            # same setup, different measurement run:
            #df_data2 = evaluate("../prrt/out/s+same.csv", "../prrt/out/r+same.csv", config=config, kind=0)
            # different setup:
            df_data2 = evaluate("../prrt/out/s+send.csv", "../prrt/out/r+send.csv", config=config, kind=0)
            difference.analyse(df_data1, df_data2, config)
        else:
            df_data = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)