From ebc8eb60be3586c7f2e61b066beba69873c6200e Mon Sep 17 00:00:00 2001 From: ggbdpq Date: Tue, 29 Sep 2026 07:04:07 +0800 Subject: [PATCH 1/3] perf(desktop): add a Usage tab-entry measurement spec and a 409-record fixture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: #4677 item 4 asks for a Usage settings tab-entry median/p95 number plus renderer-side evidence that the activity table mounts a bounded page instead of every row. Fixture (test infra only): - scenarios-usage.ts pads the 5 handcrafted turns with 394 zero-tool turns (132/131/131 across the three sessions) so the ledger holds exactly 409 activity rows: 399 model rows + 10 tool rows. Synthetic turns reuse the handcrafted generators on the fixed clock (60..453 minutes ago). - e2e-fixture.ts: one catchUpModelCallProjection() pass bounds how many lagging runs it folds, so a padded seed with hundreds of queued runs left most of them unfolded after seeding. Fold in a loop until pendingRuns reaches 0, which is generic for any large canonical seed. Spec (perf/usage-tab-entry.spec.ts): a custom usageWindow fixture injects the settings-usage scenario; the test asserts the bounded mount (DOM rows <= 50 with the tab badge at 409) and then samples 12 warm re-entry rounds entirely inside the renderer with rAF — the clock runs from the synthetic click to the activity table's next painted frame, excluding Playwright round-trips. Results land in $TEMP/usage-tab-entry-results.json. Numbers (this branch, apache/main base): median 103.9 ms, p95 142.6 ms (n=12, p95 = max), first-entry DOM rows 50/409. Reference numbers from #4677 (comment issuecomment-5880047554, measured on a feature branch): median 134.1 ms, p95 201.3 ms — same magnitude; the branch difference is noted rather than compared. Generated-by: GLM-5.3-Flash (ZCode) --- apps/desktop/perf/usage-tab-entry.spec.ts | 182 ++++++++++++++++++ apps/desktop/src/main/e2e-fixture.ts | 7 +- .../src/main/e2e-fixture/scenarios-usage.ts | 30 +++ 3 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 apps/desktop/perf/usage-tab-entry.spec.ts diff --git a/apps/desktop/perf/usage-tab-entry.spec.ts b/apps/desktop/perf/usage-tab-entry.spec.ts new file mode 100644 index 00000000000..b86203c190a --- /dev/null +++ b/apps/desktop/perf/usage-tab-entry.spec.ts @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { mkdir, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import type { ElectronApplication, Page } from '@playwright/test'; +import { expect, test as base, withE2eWindow } from '../e2e/fixtures'; + +// #4677 item 4: weigh leaving and re-entering the Usage settings section with +// a ledger that would once have mounted every activity row. The table is a +// native (BaseTable), the section tabs render as buttons inside a +// plain