fix looping with JS/TS
This commit is contained in:
parent
43a6ce1c8d
commit
12294cafb6
6 changed files with 28 additions and 13 deletions
|
|
@ -536,7 +536,9 @@ def run_mocha_benchmarking_tests(
|
|||
)
|
||||
mocha_env["CODEFLASH_TEST_MODULE"] = test_module_path
|
||||
|
||||
total_timeout = max(120, (target_duration_ms // 1000) + 60, timeout or 120)
|
||||
# Total timeout: allow headroom for Mocha startup. Behavioral tests use 600s;
|
||||
# benchmarking should be comparably generous.
|
||||
total_timeout = max(120, (target_duration_ms // 1000) + 120, (timeout or 60) * 5)
|
||||
|
||||
logger.debug(f"Running Mocha benchmarking tests: {' '.join(mocha_cmd)}")
|
||||
logger.debug(
|
||||
|
|
|
|||
|
|
@ -2372,9 +2372,14 @@ class JavaScriptSupport:
|
|||
candidate_index=candidate_index,
|
||||
)
|
||||
|
||||
# JavaScript/TypeScript benchmarking uses high max_loops like Python (100,000)
|
||||
# The actual loop count is limited by target_duration_seconds, not max_loops
|
||||
JS_BENCHMARKING_MAX_LOOPS = 100_000
|
||||
# Max iterations per capturePerf call site. Each iteration writes a timing
|
||||
# marker to stdout (~200 bytes). With N perf test cases this produces
|
||||
# N * max_loops markers flowing through Vitest's fork IPC pipe + Python
|
||||
# subprocess pipe. 100k caused 20-200 MB of stdout for micro-functions,
|
||||
# creating pipe backpressure that inflated wall-clock time past the
|
||||
# subprocess timeout. 5000 keeps stdout under 10 MB while still providing
|
||||
# enough data points for stable timing measurements.
|
||||
JS_BENCHMARKING_MAX_LOOPS = 5_000
|
||||
|
||||
def run_benchmarking_tests(
|
||||
self,
|
||||
|
|
@ -2384,7 +2389,7 @@ class JavaScriptSupport:
|
|||
timeout: int | None = None,
|
||||
project_root: Path | None = None,
|
||||
min_loops: int = 5,
|
||||
max_loops: int = 100_000,
|
||||
max_loops: int = 5_000,
|
||||
target_duration_seconds: float = 10.0,
|
||||
test_framework: str | None = None,
|
||||
) -> tuple[Path, Any]:
|
||||
|
|
|
|||
|
|
@ -1025,9 +1025,9 @@ def run_jest_benchmarking_tests(
|
|||
if "--max-old-space-size" not in existing_node_options:
|
||||
jest_env["NODE_OPTIONS"] = f"{existing_node_options} --max-old-space-size=4096".strip()
|
||||
|
||||
# Total timeout for the entire benchmark run (longer than single-loop timeout)
|
||||
# Account for startup overhead + target duration + buffer
|
||||
total_timeout = max(120, (target_duration_ms // 1000) + 60, timeout or 120)
|
||||
# Total timeout: allow headroom for Jest startup and TS compilation.
|
||||
# Behavioral tests use 600s; benchmarking should be comparably generous.
|
||||
total_timeout = max(120, (target_duration_ms // 1000) + 120, (timeout or 60) * 5)
|
||||
|
||||
logger.debug(f"Running Jest benchmarking tests with in-process loop runner: {' '.join(jest_cmd)}")
|
||||
logger.debug(
|
||||
|
|
|
|||
|
|
@ -616,8 +616,10 @@ def run_vitest_benchmarking_tests(
|
|||
vitest_env["CODEFLASH_TEST_MODULE"] = test_module_path
|
||||
logger.debug(f"[VITEST-BENCH] Set CODEFLASH_TEST_MODULE={test_module_path}")
|
||||
|
||||
# Total timeout for the entire benchmark run
|
||||
total_timeout = max(120, (target_duration_ms // 1000) + 60, timeout or 120)
|
||||
# Total timeout: allow headroom for Vitest startup (TS compilation, module resolution)
|
||||
# which can take 30-60s in monorepos. Behavioral tests use 600s; benchmarking
|
||||
# should be at least as generous.
|
||||
total_timeout = max(120, (target_duration_ms // 1000) + 120, (timeout or 60) * 5)
|
||||
|
||||
logger.debug(f"[VITEST-BENCH] Running Vitest benchmarking tests: {' '.join(vitest_cmd)}")
|
||||
logger.debug(
|
||||
|
|
|
|||
|
|
@ -773,7 +773,13 @@ class InvocationId:
|
|||
test_src = test_path.read_text(encoding="utf-8")
|
||||
module_node = cst.parse_module(test_src)
|
||||
except Exception:
|
||||
return None
|
||||
# libcst can't parse non-Python files (JS/TS) — return a descriptive string
|
||||
# so the code repair API receives a non-None test_src_code.
|
||||
return (
|
||||
f"// Test: {self.test_function_name}\n"
|
||||
f"// File: {test_path.name}\n"
|
||||
f"// Testing function: {self.function_getting_tested}"
|
||||
)
|
||||
|
||||
if self.test_class_name:
|
||||
for stmt in module_node.body:
|
||||
|
|
|
|||
|
|
@ -182,9 +182,9 @@ class TestBenchmarkingTestsDispatch:
|
|||
|
||||
call_kwargs = mock_vitest_runner.call_args.kwargs
|
||||
assert call_kwargs["min_loops"] == 10
|
||||
# JS/TS always uses high max_loops (100_000) regardless of passed value
|
||||
# JS/TS uses JS_BENCHMARKING_MAX_LOOPS (5_000) regardless of passed value
|
||||
# Actual loop count is limited by target_duration, not max_loops
|
||||
assert call_kwargs["max_loops"] == 100_000
|
||||
assert call_kwargs["max_loops"] == 5_000
|
||||
assert call_kwargs["target_duration_ms"] == 5000
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue