Skip to content

Commit cc678ba

Browse files
authored
Merge pull request #1509 from codeflash-ai/fix/js-capture-perf-for-external-runner
[FIX][JS] capturePerf shouldn't break when we have an external runner (batch size = 1)
2 parents 110e9b8 + 7308afe commit cc678ba

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

codeflash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These version placeholders will be replaced by uv-dynamic-versioning during build.
2-
__version__ = "0.20.0.post634.dev0+2d73cf88"
2+
__version__ = "0.20.0"

packages/codeflash/runtime/capture.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,12 @@ function capturePerf(funcName, lineId, fn, ...args) {
713713

714714
for (let batchIndex = 0; batchIndex < batchSize; batchIndex++) {
715715
// Check shared time limit BEFORE each iteration
716-
if (shouldLoop && checkSharedTimeLimit()) {
716+
if (!hasExternalLoopRunner && shouldLoop && checkSharedTimeLimit()) {
717717
break;
718718
}
719719

720720
// Check if this invocation has already reached stability
721-
if (getPerfStabilityCheck() && sharedPerfState.stableInvocations[invocationKey]) {
721+
if (!hasExternalLoopRunner && getPerfStabilityCheck() && sharedPerfState.stableInvocations[invocationKey]) {
722722
break;
723723
}
724724

@@ -727,7 +727,7 @@ function capturePerf(funcName, lineId, fn, ...args) {
727727

728728
// Check if we've exceeded max loops for this invocation
729729
const totalIterations = getTotalIterations(invocationKey);
730-
if (totalIterations > getPerfLoopCount()) {
730+
if (!hasExternalLoopRunner && totalIterations > getPerfLoopCount()) {
731731
break;
732732
}
733733

@@ -779,7 +779,7 @@ function capturePerf(funcName, lineId, fn, ...args) {
779779
}
780780

781781
// Check stability after accumulating enough samples
782-
if (getPerfStabilityCheck() && runtimes.length >= getPerfMinLoops()) {
782+
if (!hasExternalLoopRunner && getPerfStabilityCheck() && runtimes.length >= getPerfMinLoops()) {
783783
const window = getStabilityWindow();
784784
if (shouldStopStability(runtimes, window, getPerfMinLoops())) {
785785
sharedPerfState.stableInvocations[invocationKey] = true;
@@ -788,7 +788,7 @@ function capturePerf(funcName, lineId, fn, ...args) {
788788
}
789789

790790
// If we had an error, stop looping
791-
if (lastError) {
791+
if (!hasExternalLoopRunner && lastError) {
792792
break;
793793
}
794794
}

0 commit comments

Comments
 (0)