Skip to content

Commit d3afd8a

Browse files
committed
Update critic.py
1 parent aba3dcb commit d3afd8a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

codeflash/result/critic.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,26 @@ def speedup_critic(
7373
# Check runtime comparison with best so far
7474
runtime_is_best = best_runtime_until_now is None or candidate_result.best_test_runtime < best_runtime_until_now
7575

76-
# Async throughput evaluation (if throughput data is available)
7776
throughput_improved = True # Default to True if no throughput data
7877
throughput_is_best = True # Default to True if no throughput data
7978

8079
if original_async_throughput is not None and candidate_result.async_throughput is not None:
81-
if original_async_throughput > 0: # Avoid division by zero
80+
if original_async_throughput > 0:
8281
throughput_gain_value = throughput_gain(
8382
original_throughput=original_async_throughput, optimized_throughput=candidate_result.async_throughput
8483
)
8584
throughput_improved = throughput_gain_value > MIN_THROUGHPUT_IMPROVEMENT_THRESHOLD
86-
logger.debug(
85+
logger.info(
8786
f"Async throughput gain: {throughput_gain_value * 100:.1f}% (original: {original_async_throughput}, optimized: {candidate_result.async_throughput})"
8887
)
8988

9089
throughput_is_best = (
9190
best_throughput_until_now is None or candidate_result.async_throughput > best_throughput_until_now
9291
)
9392

94-
# For async functions with throughput data, both runtime and throughput should improve
95-
# For sync functions or when throughput data is unavailable, only runtime matters
9693
if original_async_throughput is not None and candidate_result.async_throughput is not None:
97-
return runtime_improved and runtime_is_best and throughput_improved and throughput_is_best
94+
# prioritize throughput improvement
95+
return (throughput_improved and throughput_is_best) and (runtime_improved or runtime_is_best)
9896
return runtime_improved and runtime_is_best
9997

10098

0 commit comments

Comments
 (0)