brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 02afa4a Raw
51 lines · python
1#!/usr/bin/env python2 3import json, sys, time4 5 6def is_inside(range1, range2):7    a = range1["ts"]8    b = a + range1["dur"]9    c = range2["ts"]10    d = c + range2["dur"]11    return (a >= c and a <= d) and (b >= c and b <= d)12 13 14def is_before(range1, range2):15    b = range1["ts"] + range1["dur"]16    c = range2["ts"]17    return b <= c18 19 20log_contents = json.loads(sys.stdin.read())21events = log_contents["traceEvents"]22codegens = [event for event in events if event["name"] == "CodeGen Function"]23frontends = [event for event in events if event["name"] == "Frontend"]24backends = [event for event in events if event["name"] == "Backend"]25 26beginning_of_time = log_contents["beginningOfTime"] / 100000027seconds_since_epoch = time.time()28 29# Make sure that the 'beginningOfTime' is not later than now.30if beginning_of_time > seconds_since_epoch:31    sys.exit(32        "'beginningOfTime' should represent the absolute time when the "33        "process has started"34    )35 36if not all(37    [38        any([is_inside(codegen, frontend) for frontend in frontends])39        for codegen in codegens40    ]41):42    sys.exit("Not all CodeGen sections are inside any Frontend section!")43 44if not all(45    [46        all([is_before(frontend, backend) for frontend in frontends])47        for backend in backends48    ]49):50    sys.exit("Not all Frontend section are before all Backend sections!")51