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

Speed-up happens before by using pandas logical operations.

parent b6c6d92d
Loading
Loading
Loading
Loading
+6 −15
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ def _happens_before(df, a, b, config):
    """
    check if a happens-before b in the trace
    """
    l = len(df[a])
    # check whether a and b occur in the same thread. If so, a and b cannot be
    # concurrent.
    ta = _get_thread_for_event(config, a)
@@ -25,23 +24,15 @@ def _happens_before(df, a, b, config):
    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:
        tg = df[a] > df[b]
        if tg.any():
            return False
            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
        df2 = df[df[a] == df[b]]
        return not ((df2[cname_a] > df2[cname_b]) & df2[cname_b] != 0).any()

    # since a and b occur in different threads, we cannot compare cyclestamps.
    # If in doubt, a and b are concurrent.
    for i in range(l):
        if df[a].iloc[i] >= df[b].iloc[i]:
            return False
    return True
    return not (df[a] >= df[b]).any()

def _fast_happens_before(df, a, b, hb):
    """