@mui/internal-benchmark 0.0.3-canary.8 → 0.1.1-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
+ import * as React from 'react';
1
2
  export declare function ElementTiming({
2
3
  name
3
4
  }: {
4
5
  name: string;
5
- }): import("react/jsx-runtime").JSX.Element;
6
+ }): React.JSX.Element;
package/Metric.mjs CHANGED
@@ -33,6 +33,8 @@ function flush(test, accumulator) {
33
33
  * tests and loop iterations, inside or outside React.
34
34
  */
35
35
  export class Metric {
36
+ name;
37
+ config;
36
38
  constructor(config) {
37
39
  this.config = typeof config === 'string' ? {
38
40
  name: config
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/internal-benchmark v0.0.2
2
+ * @mui/internal-benchmark v0.1.0
3
3
  *
4
4
  * @license undefined
5
5
  * This source code is licensed under the undefined license found in the
@@ -206,17 +206,15 @@ export function benchmark(name, renderFn, interactionOrOptions, maybeOptions) {
206
206
 
207
207
  // Paint timings are recorded as one harness-owned `bench:paint` metric: the default sentinel
208
208
  // is the base series (`bench:paint`) and named `elementtiming` markers are sub-series
209
- // (`bench:paint#grid-header`, …), all sharing a single definition. A default alarm keeps a
210
- // >20% paint regression flagged, matching the previous behavior.
209
+ // (`bench:paint#grid-header`, …), all sharing a single definition. Paint is informational (no
210
+ // alarm): it dominates each test's total duration, so a per-test paint alarm just duplicates the
211
+ // Duration regression signal and floods the report on any broadly-regressed run.
211
212
  const paint = new ScalarMetric({
212
213
  name: 'bench:paint',
213
214
  format: {
214
215
  style: 'unit',
215
216
  unit: 'millisecond',
216
217
  maximumFractionDigits: 2
217
- },
218
- alarm: {
219
- error: 0.2
220
218
  }
221
219
  });
222
220
  if (typeof window.gc !== 'function') {
@@ -286,13 +284,13 @@ export function benchmark(name, renderFn, interactionOrOptions, maybeOptions) {
286
284
  if (!isWarmup) {
287
285
  for (const entry of timing.elementEntries) {
288
286
  // Skip paints that happened while recording was paused. Attribute by the paint's
289
- // `renderTime`, not by when the observer callback fired (which can lag the paint).
290
- if (!recording.activeAt(entry.renderTime)) {
287
+ // `paintTime`, not by when the observer callback fired (which can lag the paint).
288
+ if (!recording.activeAt(entry.paintTime)) {
291
289
  continue;
292
290
  }
293
291
  // The default sentinel is the base series; named markers become sub-series.
294
292
  const id = entry.identifier === 'default' ? undefined : entry.identifier;
295
- paint.record(entry.renderTime - iterationStart, id !== undefined ? {
293
+ paint.record(entry.paintTime - iterationStart, id !== undefined ? {
296
294
  id
297
295
  } : undefined);
298
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-benchmark",
3
- "version": "0.0.3-canary.8",
3
+ "version": "0.1.1-canary.0",
4
4
  "author": "MUI Team",
5
5
  "description": "Benchmark utilities for MUI projects. Internal package.",
6
6
  "repository": {
@@ -9,11 +9,11 @@
9
9
  "directory": "packages/benchmark"
10
10
  },
11
11
  "dependencies": {
12
- "@babel/runtime": "^7.29.2",
13
- "@vitejs/plugin-react": "^6.0.2",
12
+ "@babel/runtime": "^8.0.5",
13
+ "@vitejs/plugin-react": "^6.1.1",
14
14
  "env-ci": "^11.2.0",
15
- "execa": "^9.6.1",
16
- "zod": "^4.4.3"
15
+ "execa": "^10.0.1",
16
+ "zod": "^4.6.4"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@vitest/browser-playwright": ">=4.1",
@@ -68,5 +68,5 @@
68
68
  }
69
69
  }
70
70
  },
71
- "gitSha": "f0490c402ec0640d9b3687fd1e1e827bfa9c1610"
71
+ "gitSha": "764e3b3cfc14293e74e93f3413609025f502bab9"
72
72
  }
@@ -5,7 +5,7 @@ export interface ReactRecordingControls {
5
5
  readonly hadEmptyActiveWindow: boolean;
6
6
  /**
7
7
  * Whether recording was active at `time` (a `performance.now()` timestamp). Paint entries are
8
- * observed asynchronously, so they are attributed by their `renderTime` rather than by the
8
+ * observed asynchronously, so they are attributed by their `paintTime` rather than by the
9
9
  * recording state at the moment the observer callback happens to fire.
10
10
  */
11
11
  activeAt(time: number): boolean;
package/reporter.mjs CHANGED
@@ -240,6 +240,9 @@ async function loadBaselineReport(baselinePath) {
240
240
  class BenchmarkReporter {
241
241
  benchmarks = {};
242
242
  metricDefinitions = {};
243
+ outputPath;
244
+ upload;
245
+ baselinePath;
243
246
  hasFailures = false;
244
247
  constructor(options) {
245
248
  this.outputPath = options?.outputPath ?? process.env.BENCHMARK_OUTPUT_PATH ?? path.resolve(process.cwd(), 'benchmarks', 'results.json');
package/vitest.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ViteUserConfig } from 'vitest/config';
1
+ import type { ViteUserConfig } from 'vitest/config';
2
2
  export interface CreateBenchmarkVitestConfigOptions {
3
3
  /**
4
4
  * Path to save benchmark results JSON file. If not provided, results will not be saved to disk.
package/vitest.mjs CHANGED
@@ -34,6 +34,18 @@ function resolveViewport(option) {
34
34
  // workload needs them.
35
35
  const LAUNCH_ARGS = ['--js-flags=--expose-gc', '--disable-background-timer-throttling', '--disable-backgrounding-occluded-windows', '--disable-renderer-backgrounding'];
36
36
  export function createBenchmarkVitestConfig(options) {
37
+ // Benchmarks have to measure production React, which is why the config below sets NODE_ENV to
38
+ // "production" for the code running in the browser. That alone isn't enough: Vite picks which
39
+ // JSX runtime to compile against by reading NODE_ENV from the Node process, where Vitest has set
40
+ // it to "test". Benchmarks then get development JSX calling into a production React build, which
41
+ // has no `jsxDEV` function, and every benchmark crashes on its first render with
42
+ // "_jsxDEV is not a function".
43
+ //
44
+ // Setting NODE_ENV here, while this config file is still being evaluated, means Vite reads
45
+ // "production" as well and the two agree. Vitest considers this the intended way to run tests
46
+ // against production React: https://github.com/vitest-dev/vitest/issues/11265
47
+ // eslint-disable-next-line mui/consistent-production-guard -- an assignment, not a guard
48
+ process.env.NODE_ENV = 'production';
37
49
  const {
38
50
  outputPath,
39
51
  baselinePath,