6 def is_inside(range1
, range2
):
11 return (a
>= c
and a
<= d
) and (b
>= c
and b
<= d
)
14 def is_before(range1
, range2
):
15 b
= range1
["ts"] + range1
["dur"]
20 log_contents
= json
.loads(sys
.stdin
.read())
21 events
= log_contents
["traceEvents"]
22 codegens
= [event
for event
in events
if event
["name"] == "CodeGen Function"]
23 frontends
= [event
for event
in events
if event
["name"] == "Frontend"]
24 backends
= [event
for event
in events
if event
["name"] == "Backend"]
26 beginning_of_time
= log_contents
["beginningOfTime"] / 1000000
27 seconds_since_epoch
= time
.time()
29 # Make sure that the 'beginningOfTime' is not later than now.
30 if beginning_of_time
> seconds_since_epoch
:
32 "'beginningOfTime' should represent the absolute time when the "
38 any([is_inside(codegen
, frontend
) for frontend
in frontends
])
39 for codegen
in codegens
42 sys
.exit("Not all CodeGen sections are inside any Frontend section!")
46 all([is_before(frontend
, backend
) for frontend
in frontends
])
47 for backend
in backends
50 sys
.exit("Not all Frontend section are before all Backend sections!")