@@ -204,7 +204,7 @@ def dump_graph_json(self, graph):
204204 with open (os .path .join (self ._dump_path , graph_dump_file_name ), 'w' ) as outfile :
205205 json .dump (graph , outfile , indent = 4 , sort_keys = False )
206206
207- def display_debug_result (self ):
207+ def display_debug_result (self , sort_by_time = True ):
208208 """Displays the debugger result"
209209 """
210210 header = ["Node Name" , "Ops" , "Time(us)" , "Time(%)" , "Shape" , "Inputs" , "Outputs" ]
@@ -228,6 +228,14 @@ def display_debug_result(self):
228228 node_data = [name , op , time_us , time_percent , shape , inputs , outputs ]
229229 data .append (node_data )
230230 eid += 1
231+
232+ if sort_by_time :
233+ # Sort on the basis of execution time. Prints the most expensive ops in the start.
234+ data = sorted (data , key = lambda x : x [2 ], reverse = True )
235+ # Insert a row for total time at the end.
236+ rounded_total_time = round (total_time * 1000000 , 3 )
237+ data .append (["Total_time" , "-" , rounded_total_time , "-" , "-" , "-" , "-" , "-" ])
238+
231239 fmt = ""
232240 for i , _ in enumerate (header ):
233241 max_len = len (header [i ])
0 commit comments