File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,9 @@ def leave_SimpleStatementLine(
131131 if matching_original_times and matching_optimized_times :
132132 original_time = min (matching_original_times )
133133 optimized_time = min (matching_optimized_times )
134- perf_gain = performance_gain (original_runtime_ns = original_time , optimized_runtime_ns = optimized_time )
134+ perf_gain = (
135+ performance_gain (original_runtime_ns = original_time , optimized_runtime_ns = optimized_time ) * 100
136+ )
135137 # Create the runtime comment
136138 comment_text = f"# { format_time (original_time )} -> { format_time (optimized_time )} ({ perf_gain :.2f} %)"
137139
Original file line number Diff line number Diff line change @@ -99,9 +99,12 @@ def existing_tests_source_for(
9999 optimized_tests_to_runtimes [filename ][qualified_name ]
100100 > original_tests_to_runtimes [filename ][qualified_name ]
101101 )
102- perf_gain = performance_gain (
103- original_runtime_ns = original_tests_to_runtimes [filename ][qualified_name ],
104- optimized_runtime_ns = optimized_tests_to_runtimes [filename ][qualified_name ],
102+ perf_gain = (
103+ performance_gain (
104+ original_runtime_ns = original_tests_to_runtimes [filename ][qualified_name ],
105+ optimized_runtime_ns = optimized_tests_to_runtimes [filename ][qualified_name ],
106+ )
107+ * 100
105108 )
106109 if greater :
107110 output += f" - { qualified_name } : { print_original_runtime } { arrow } { print_optimized_runtime } $$\\ color{{red}}({ perf_gain :.2f} \\ \\ %)$$\n "
Original file line number Diff line number Diff line change 1212 TestType ,
1313 VerificationType ,
1414)
15+ from codeflash .verification .verification_utils import TestConfig
1516
1617
1718class TestAddRuntimeComments :
@@ -48,6 +49,18 @@ def test_basic_runtime_comment_addition(self):
4849 assert codeflash_output == [1, 2, 3]
4950"""
5051
52+ """test_cfg: TestConfig,
53+ generated_tests: GeneratedTestsList,
54+ original_runtimes: dict[InvocationId, list[int]],
55+ optimized_runtimes: dict[InvocationId, list[int]]"""
56+ project_root_path = file_path .parent .resolve ()
57+ test_config = TestConfig (
58+ tests_root = "tests" ,
59+ tests_project_rootdir = Path .cwd (),
60+ project_root_path = project_root_path ,
61+ test_framework = "pytest" ,
62+ pytest_cmd = "pytest" ,
63+ )
5164 generated_test = GeneratedTests (
5265 generated_original_test_source = test_source ,
5366 instrumented_behavior_test_source = "" ,
You can’t perform that action at this time.
0 commit comments