28 """Find critical path, print algorithms on it and its length."""
30 assert tuple(map(int, nx.__version__.split(
"."))) >= (
33 ),
"This script requires Networkx version 2.0 or higher"
35 trace = nx.read_graphml(path_to_trace_file)
37 for inNode, outNode, edge_attrs
in trace.in_edges(data=
True):
38 edge_attrs[
"Runtime"] = nx.get_node_attributes(trace,
"Run Time (us)")[outNode]
40 cpath = nx.algorithms.dag.dag_longest_path(trace, weight=
"Runtime")
42 print(
"Algorithms on the critical path (%i): " % len(cpath))
44 print(
" {:<40} Runtime (us)".
format(
"Name"))
45 print(
" -----------------------------------------------------")
49 trace.nodes[node_id].get(
"Name"),
50 trace.nodes[node_id].get(
"Run Time (us)"),
55 "\nTotal critical path time: ",
56 nx.algorithms.dag.dag_longest_path_length(trace, weight=
"Runtime"),