-
Notifications
You must be signed in to change notification settings - Fork 570
[code-simplifier] Simplify benchmark --parentProcess flow #26954
Copy link
Copy link
Open
Description
Overview
This PR applies small readability-focused simplifications to the newly-added benchmark runner code, without changing behavior.
Files simplified
tools/benchmark/src/mocha/benchmarkIt.ts- Remove redundant
async/awaitwrappers when forwarding promises.
- Remove redundant
tools/benchmark/src/mocha/runner.ts- Extract small helpers (
escapeRegExp, reusable regexes) and useRegExp.testfor clearer intent.
- Extract small helpers (
Changes based on
- Fixed
--parentProcessmode partial match #26948 (commitf7ff4ec) —--parentProcessexact-match filtering fix.
Testing
pnpm -C tools/benchmark lintpnpm -C tools/benchmark build:compilepnpm -C tools/benchmark test
References:
Generated by Code Simplifier · ◷
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/code-simplifier.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
- expires on Apr 8, 2026, 7:49 AM UTC
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/benchmark-parentprocess-cleanup-4a746b83d73b7dfa.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests.
Show patch preview (88 of 88 lines)
From f0db82e1be4eea4c7b68d65ac4fca07a2c5c6416 Mon Sep 17 00:00:00 2001
From: code-simplifier <code-simplifier@users.noreply.github.com>
Date: Tue, 7 Apr 2026 07:47:18 +0000
Subject: [PATCH] Simplify benchmark parent process handling
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
tools/benchmark/src/mocha/benchmarkIt.ts | 8 +++-----
tools/benchmark/src/mocha/runner.ts | 15 +++++++++++----
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/tools/benchmark/src/mocha/benchmarkIt.ts b/tools/benchmark/src/mocha/benchmarkIt.ts
index 99babd4..601a720 100644
--- a/tools/benchmark/src/mocha/benchmarkIt.ts
+++ b/tools/benchmark/src/mocha/benchmarkIt.ts
@@ -40,11 +40,9 @@ export function benchmarkIt(options: BenchmarkOptions): Test {
const test = itFunction(title, async () => {
// Emits the "benchmark end" event with the result
await emitResultsMocha(
- async () =>
- await supportParentProcess(
- test.fullTitle(),
- useParentProcess && !isChildProcess,
- async () => await options.run(timer),
+ () =>
+ supportParentProcess(test.fullTitle(), useParentProcess && !isChildProcess, () =>
+ options.run(timer),
),
test,
);
diff --git a/tools/benchmark/src/mocha/runner.ts b/tools/benchmark/src/mocha/runner.ts
index 48dfe3f..baf3f35 100644
--- a/tools/benchmark/src/mocha/runner.ts
+++ b/tools/benchmark/src/mocha/runner.ts
@@ -13,6 +13,13 @@ import {
import { captureResults } from "../benchmarkAuthoringUtilities.js";
import { fail } from "../assert.js";
+const inspectOrDebugArgRegex = /^(--inspect|--debug)/;
+const jsonLineRegex = /^(\[.*\]|\{.*\})$/;
+
+function escapeRegExp(value: string): string {
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+}
+
/**
* Wrapper for the contents of a mocha test that supports running in a child process and emitting results to the mocha reporter.
*/
@@ -21,7 +28,7 @@ export async function supportParentProcess(
isParentProcess: boolean,
run:
... (truncated)Reactions are currently unavailable