Skip to content

Commit 04d31b5

Browse files
committed
optimized candidate result oo
1 parent e5c4562 commit 04d31b5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

codeflash/models/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ class OptimizedCandidateResult(BaseModel):
274274
replay_benchmarking_test_results: Optional[dict[BenchmarkKey, TestResults]] = None
275275
optimization_candidate_index: int
276276
total_candidate_timing: int
277+
async_throughput: Optional[int] = None
277278

278279

279280
class GeneratedTests(BaseModel):

codeflash/optimization/function_optimizer.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,19 @@ def run_optimized_candidate(
16721672
console.rule()
16731673

16741674
logger.debug(f"Total optimized code {optimization_candidate_index} runtime (ns): {total_candidate_timing}")
1675+
1676+
candidate_async_throughput = None
1677+
if self.function_to_optimize.is_async and candidate_benchmarking_results:
1678+
all_stdout = ""
1679+
for result in candidate_benchmarking_results.test_results:
1680+
if result.stdout:
1681+
all_stdout += result.stdout
1682+
1683+
1684+
candidate_async_throughput = calculate_function_throughput_from_stdout(
1685+
all_stdout, self.function_to_optimize.function_name
1686+
)
1687+
16751688
if self.args.benchmark:
16761689
candidate_replay_benchmarking_results = candidate_benchmarking_results.group_by_benchmarks(
16771690
self.total_benchmark_timings.keys(), self.replay_tests_dir, self.project_root
@@ -1691,6 +1704,7 @@ def run_optimized_candidate(
16911704
else None,
16921705
optimization_candidate_index=optimization_candidate_index,
16931706
total_candidate_timing=total_candidate_timing,
1707+
async_throughput=candidate_async_throughput,
16941708
)
16951709
)
16961710

0 commit comments

Comments
 (0)