99import os
1010import sys
1111import re
12+ import time
1213from pathlib import Path
1314from typing import List , Sequence , Tuple
1415
@@ -747,9 +748,12 @@ def py_sequence_loop(exp) -> None:
747748 _ensure_target_output_writable (short_file_bases )
748749
749750 for frame in range (first_frame , last_frame + 1 ):
751+ frame_start = time .perf_counter ()
752+ print (f"[TIMING] frame { frame } : start" )
750753 detections = []
751754 corrected = []
752755 for i_cam in range (num_cams ):
756+ cam_start = time .perf_counter ()
753757 if existing_target :
754758 targs = read_targets (short_file_bases [i_cam ], frame )
755759 else :
@@ -779,6 +783,11 @@ def py_sequence_loop(exp) -> None:
779783 high_pass = simple_highpass (img , cpar )
780784 targs = target_recognition (high_pass , tpar , i_cam , cpar )
781785
786+ print (
787+ f"[TIMING] frame { frame } cam { i_cam + 1 } : detection finished in "
788+ f"{ time .perf_counter () - cam_start :.3f} s with { len (targs )} targets"
789+ )
790+
782791 if len (targs ) > 0 :
783792 targs = sort_target_y (targs )
784793
@@ -791,14 +800,20 @@ def py_sequence_loop(exp) -> None:
791800 # correspondence wrapper can use the current unified API contract.
792801 exp .detections = detections
793802 exp .corrected = corrected
803+ corresp_start = time .perf_counter ()
794804 sorted_pos , sorted_corresp , _ = py_correspondences_proc_c (exp , frame )
805+ print (
806+ f"[TIMING] frame { frame } : correspondences finished in "
807+ f"{ time .perf_counter () - corresp_start :.3f} s"
808+ )
795809 print (
796810 "Frame "
797811 + str (frame )
798812 + " had "
799813 + repr ([s .shape [1 ] for s in sorted_pos ])
800814 + " correspondences."
801815 )
816+ determine_start = time .perf_counter ()
802817 sorted_pos = np .concatenate (sorted_pos , axis = 1 )
803818 sorted_corresp = np .concatenate (sorted_corresp , axis = 1 )
804819 flat = np .array (
@@ -813,6 +828,10 @@ def py_sequence_loop(exp) -> None:
813828 legacy_cals ,
814829 legacy_vpar ,
815830 )
831+ print (
832+ f"[TIMING] frame { frame } : determination finished in "
833+ f"{ time .perf_counter () - determine_start :.3f} s"
834+ )
816835 if len (exp .cals ) < 4 :
817836 print_corresp = - 1 * np .ones ((4 , sorted_corresp .shape [1 ]))
818837 print_corresp [: len (exp .cals ), :] = sorted_corresp
@@ -826,6 +845,7 @@ def py_sequence_loop(exp) -> None:
826845 for pix , pt in enumerate (pos ):
827846 pt_args = (pix + 1 ,) + tuple (pt ) + tuple (print_corresp [:, pix ])
828847 rt_is .write ("%4d %9.3f %9.3f %9.3f %4d %4d %4d %4d\n " % pt_args )
848+ print (f"[TIMING] frame { frame } : total loop time { time .perf_counter () - frame_start :.3f} s" )
829849 except OSError as exc :
830850 _raise_output_write_error (output_path , exc )
831851
0 commit comments