mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
fix: calculate MAX_BATCHES correctly in Jest loop-runner
Previously, MAX_BATCHES was set to PERF_LOOP_COUNT directly (e.g., 250), which caused the loop-runner to run 250 batches even though only 25 batches were needed to produce timing data (with BATCH_SIZE=10). The bug was that timing markers only appeared for the first N batches (where N = LOOP_COUNT / BATCH_SIZE), and the remaining batches were wasted overhead. Fix: Calculate MAX_BATCHES as ceil(LOOP_COUNT / BATCH_SIZE) + 1, capped at LOOP_COUNT. This ensures only the necessary batches run: - With LOOP_COUNT=250, BATCH_SIZE=10: MAX_BATCHES = 26 (not 250) This significantly improves benchmark efficiency by eliminating wasted Jest passes that don't contribute timing data. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2cee81bb5d
commit
5296dc8321
1 changed files with 5 additions and 1 deletions
|
|
@ -32,7 +32,11 @@ const internalRequire = createRequire(jestRunnerPath);
|
|||
const runTest = internalRequire('./runTest').default;
|
||||
|
||||
// Configuration
|
||||
const MAX_BATCHES = parseInt(process.env.CODEFLASH_PERF_LOOP_COUNT || '10000', 10);
|
||||
const PERF_LOOP_COUNT = parseInt(process.env.CODEFLASH_PERF_LOOP_COUNT || '10000', 10);
|
||||
const PERF_BATCH_SIZE = parseInt(process.env.CODEFLASH_PERF_BATCH_SIZE || '10', 10);
|
||||
// MAX_BATCHES = how many batches needed to reach PERF_LOOP_COUNT iterations
|
||||
// Add 1 to handle any rounding, but cap at PERF_LOOP_COUNT to avoid excessive batches
|
||||
const MAX_BATCHES = Math.min(Math.ceil(PERF_LOOP_COUNT / PERF_BATCH_SIZE) + 1, PERF_LOOP_COUNT);
|
||||
const TARGET_DURATION_MS = parseInt(process.env.CODEFLASH_PERF_TARGET_DURATION_MS || '10000', 10);
|
||||
const MIN_BATCHES = parseInt(process.env.CODEFLASH_PERF_MIN_LOOPS || '5', 10);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue