Commit b6c6d92d authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Further speedup by making cycle stamp access faster.

parent 889213f6
Loading
Loading
Loading
Loading
+5 −12
Original line number Diff line number Diff line
@@ -4,20 +4,11 @@ from xlap.analyse.util import get_outlier_threshold, extract_durations, box
from scipy.stats.stats import pearsonr
import sys

def _get_cyclestamp(df, event, idx):
    """
    get the cyclestamp related to an *_T event
    """
    # TODO: this function is probably terribly slow
    cname = str(event)[:-2] + "_C"
    cycleevent = [x for x in list(df) if str(x) == cname][0]
    return df[cycleevent].iloc[idx]

def _get_thread_for_event(config, e):
    name = str(e)[:-2]
    try:
        question = config["stamps"][name]["Thread"]
        return question
        return config["stamps"][name]["Thread"]
    except KeyError:
        print("Cannot find %s".format(name), file=sys.stderr)
        return None
@@ -31,14 +22,16 @@ def _happens_before(df, a, b, config):
    # concurrent.
    ta = _get_thread_for_event(config, a)
    tb = _get_thread_for_event(config, b)
    cname_a = str(a)[:-2] + "_C"
    cname_b = str(b)[:-2] + "_C"
    if (ta == tb and ta != None and tb != None):
        for i in range(l):
            tsa = df[a].iloc[i]
            tsb = df[b].iloc[i]
            if tsa > tsb:
                return False
            csa = _get_cyclestamp(df, a, i)
            csb = _get_cyclestamp(df, b, i)
            csa = df[cname_a].iloc[i]
            csb = df[cname_b].iloc[i]
            if tsa == tsb and csa > csb and csb != 0:
                return False
        return True