@@ -562,27 +562,6 @@ def level_to_saturation(level):
562562 pl .vlines (cmpoint [0 ], pl .ylim ()[0 ]+ 0.001 , pl .ylim ()[1 ] - 0.001 , 'r' , '--' )
563563 pl .hlines (cmpoint [1 ], pl .xlim ()[0 ]+ 0.001 , pl .xlim ()[1 ] - 0.001 , 'r' , '--' )
564564
565- # plot timestamps, if any
566- if len (ts ) > 0 and timestamps :
567- func_num = 0
568- f_labels = function_labels (ts .keys ())
569- rectangles = {}
570- for f , exec_ts in ts .items ():
571- for execution in exec_ts :
572- x0 , x1 = execution [:2 ]
573- y0 = execution [4 ]
574- y1 = y0 + 1
575- x0 -= global_start
576- x1 -= global_start
577- color = next (colors [y0 ])
578- rect , text = add_timestamp_rectangle (
579- timestamp_ax ,
580- x0 , x1 , y0 , y1 , f ,
581- color = color
582- )
583- rectangles [(x0 , y0 , x1 , y1 )] = (f , text , rect )
584- func_num += 1
585-
586565 def mouse_motion_handler (event ):
587566 x , y = event .xdata , event .ydata
588567 if x is not None and y is not None :
@@ -630,10 +609,31 @@ def mouse_click_handler(event):
630609 pl .draw ()
631610 return
632611
633- # Disable hovering if there are too many rectangle to prevent slow down
634- if len (rectangles ) < 100 :
635- pl .gcf ().canvas .mpl_connect ('motion_notify_event' , mouse_motion_handler )
636- pl .gcf ().canvas .mpl_connect ('button_release_event' , mouse_click_handler )
612+ # plot timestamps, if any
613+ if len (ts ) > 0 and timestamps :
614+ func_num = 0
615+ f_labels = function_labels (ts .keys ())
616+ rectangles = {}
617+ for f , exec_ts in ts .items ():
618+ for execution in exec_ts :
619+ x0 , x1 = execution [:2 ]
620+ y0 = execution [4 ]
621+ y1 = y0 + 1
622+ x0 -= global_start
623+ x1 -= global_start
624+ color = next (colors [y0 ])
625+ rect , text = add_timestamp_rectangle (
626+ timestamp_ax ,
627+ x0 , x1 , y0 , y1 , f ,
628+ color = color
629+ )
630+ rectangles [(x0 , y0 , x1 , y1 )] = (f , text , rect )
631+ func_num += 1
632+
633+ # Disable hovering if there are too many rectangle to prevent slow down
634+ if len (rectangles ) < 100 :
635+ pl .gcf ().canvas .mpl_connect ('motion_notify_event' , mouse_motion_handler )
636+ pl .gcf ().canvas .mpl_connect ('button_release_event' , mouse_click_handler )
637637
638638 if timestamps :
639639 pl .hlines (max_mem ,
0 commit comments