@@ -487,8 +487,7 @@ def __init__(
487487 rel_path = os .path .relpath (str (source_file_abs ), str (tests_root_abs ))
488488 self .original_module_path = rel_path
489489 logger .debug (
490- f"!lsp|JS module path: source={ source_file_abs } , "
491- f"tests_root={ tests_root_abs } , rel_path={ rel_path } "
490+ f"!lsp|JS module path: source={ source_file_abs } , tests_root={ tests_root_abs } , rel_path={ rel_path } "
492491 )
493492 except ValueError :
494493 # Fallback if paths are on different drives (Windows)
@@ -602,15 +601,19 @@ def generate_and_instrument_tests(
602601
603602 # For JavaScript/TypeScript, copy all runtime files to tests directory
604603 if language in ("javascript" , "typescript" ):
605- from codeflash .languages .javascript .runtime import get_all_runtime_files
606604 import shutil
607605
606+ from codeflash .languages .javascript .runtime import get_all_runtime_files
607+
608608 # Copy all runtime files (helper, serializer, comparator, etc.)
609609 for runtime_file_source in get_all_runtime_files ():
610610 runtime_file_dest = self .test_cfg .tests_root / runtime_file_source .name
611611
612612 # Copy file if it doesn't exist or is outdated
613- if not runtime_file_dest .exists () or runtime_file_source .stat ().st_mtime > runtime_file_dest .stat ().st_mtime :
613+ if (
614+ not runtime_file_dest .exists ()
615+ or runtime_file_source .stat ().st_mtime > runtime_file_dest .stat ().st_mtime
616+ ):
614617 shutil .copy2 (runtime_file_source , runtime_file_dest )
615618 logger .debug (f"Copied { runtime_file_source .name } to { runtime_file_dest } " )
616619
@@ -868,7 +871,9 @@ def handle_successful_candidate(
868871 else :
869872 with progress_bar ("Running line-by-line profiling" ):
870873 line_profile_test_results = self .line_profiler_step (
871- code_context = code_context , original_helper_code = original_helper_code , candidate_index = candidate_index
874+ code_context = code_context ,
875+ original_helper_code = original_helper_code ,
876+ candidate_index = candidate_index ,
872877 )
873878
874879 eval_ctx .record_line_profiler_result (candidate .optimization_id , line_profile_test_results ["str_out" ])
@@ -2246,15 +2251,6 @@ def establish_original_code_baseline(
22462251 if (result .test_type == TestType .GENERATED_REGRESSION and not result .did_pass )
22472252 ]
22482253
2249- # For JavaScript/TypeScript: If performance benchmarking fails, use behavioral test timing as fallback
2250- if total_timing == 0 and self .function_to_optimize .language in ("javascript" , "typescript" ):
2251- behavioral_timing = behavioral_results .total_passed_runtime ()
2252- if behavioral_timing > 0 :
2253- logger .info (f"Performance benchmarking returned 0 runtime, using behavioral test timing as fallback: { behavioral_timing } ns" )
2254- total_timing = behavioral_timing
2255- # Use behavioral results for benchmarking since performance tests failed
2256- benchmarking_results = behavioral_results
2257-
22582254 if total_timing == 0 :
22592255 logger .warning ("The overall summed benchmark runtime of the original function is 0, couldn't run tests." )
22602256 console .rule ()
@@ -2438,7 +2434,9 @@ def run_optimized_candidate(
24382434 logger .error (f"Candidate SQLite database not found: { candidate_sqlite } " )
24392435 logger .debug ("No diffs found, skipping repair" )
24402436 # Use Python-style comparison on TestResults as fallback
2441- match , diffs = compare_test_results (baseline_results .behavior_test_results , candidate_behavior_results )
2437+ match , diffs = compare_test_results (
2438+ baseline_results .behavior_test_results , candidate_behavior_results
2439+ )
24422440 else :
24432441 # Python: Compare using Python comparator
24442442 match , diffs = compare_test_results (baseline_results .behavior_test_results , candidate_behavior_results )
@@ -2484,17 +2482,7 @@ def run_optimized_candidate(
24842482 else 0
24852483 )
24862484
2487- total_candidate_timing = candidate_benchmarking_results .total_passed_runtime ()
2488-
2489- # For JavaScript/TypeScript: If performance benchmarking fails, use behavioral test timing as fallback
2490- if total_candidate_timing == 0 and self .function_to_optimize .language in ("javascript" , "typescript" ):
2491- candidate_behavioral_timing = candidate_behavior_results .total_passed_runtime ()
2492- if candidate_behavioral_timing > 0 :
2493- logger .info (f"Performance benchmarking returned 0 runtime for candidate, using behavioral test timing as fallback: { candidate_behavioral_timing } ns" )
2494- total_candidate_timing = candidate_behavioral_timing
2495- candidate_benchmarking_results = candidate_behavior_results
2496-
2497- if total_candidate_timing == 0 :
2485+ if (total_candidate_timing := candidate_benchmarking_results .total_passed_runtime ()) == 0 :
24982486 logger .warning ("The overall test runtime of the optimized function is 0, couldn't run tests." )
24992487 console .rule ()
25002488
0 commit comments