Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/perf-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
- name: Compare against baselines
id: compare
working-directory: packages/e2e-test-app-fabric
env:
CI: 'true'
run: yarn perf:ci:compare
continue-on-error: true

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: reporter writes current measured values via temp files instead of baselines",
"packageName": "@react-native-windows/perf-testing",
"email": "74712637+iamAbhi-916@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export class PerfJsonReporter {
const suites: SuiteResult[] = [];

for (const suite of results.testResults) {
// Load the snapshot file for this test suite (written by toMatchPerfSnapshot)
const {file: snapshotFilePath} = SnapshotManager.getSnapshotPath(
// Load the CURRENT measured values written by toMatchPerfSnapshot
// to a temp file (not the baselines — those are for comparison only)
const snapshots = SnapshotManager.loadCurrentRun(
suite.testFilePath,
);
const snapshots = SnapshotManager.load(snapshotFilePath);

const passed = suite.testResults.filter(
t => t.status === 'passed',
Expand Down Expand Up @@ -136,6 +136,11 @@ export class PerfJsonReporter {
);

console.log(`\n📊 Perf results written to: ${this.outputFile}`);

// Clean up temp files written by test workers
for (const suite of results.testResults) {
SnapshotManager.cleanCurrentRun(suite.testFilePath);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,50 @@ export class SnapshotManager {
static buildKey(testName: string): string {
return `${testName} 1`;
}

/**
* Path to the temp file where the current run's measured values are stored.
* Written by toMatchPerfSnapshot (worker), read by PerfJsonReporter (main).
*/
static getCurrentRunPath(testFilePath: string): string {
const testDir = path.dirname(testFilePath);
const snapshotDir = path.join(testDir, '__perf_snapshots__');
return path.join(
snapshotDir,
`${path.basename(testFilePath)}.perf-current.json`,
);
}

/**
* Record a single test's measured values to the current-run temp file.
* Called from the test worker process by toMatchPerfSnapshot.
*/
static recordCurrentRun(
testFilePath: string,
key: string,
entry: SnapshotEntry,
): void {
const currentPath = this.getCurrentRunPath(testFilePath);
const existing = this.load(currentPath);
existing[key] = entry;
this.save(currentPath, existing);
}

/**
* Load the current run's measured values from the temp file.
* Called from the main process by PerfJsonReporter.
*/
static loadCurrentRun(testFilePath: string): SnapshotFile {
return this.load(this.getCurrentRunPath(testFilePath));
}

/**
* Remove the current-run temp file (cleanup after reporting).
*/
static cleanCurrentRun(testFilePath: string): void {
const p = this.getCurrentRunPath(testFilePath);
if (fs.existsSync(p)) {
fs.unlinkSync(p);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ expect.extend({
};
}

// Record current measured values for the CI reporter
SnapshotManager.recordCurrentRun(testPath, snapshotKey, {
metrics: received,
threshold,
capturedAt: new Date().toISOString(),
});

// COMPARE MODE
const {errors, warnings} = compareAgainstBaseline(
received,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class ViewPerfTest extends ComponentPerfTestBase {
const NestedViews = () => (
<View testID={this.testId} style={styles.container}>
{Array.from({length: count}, (_, i) => (
<View key={i} style={styles.nested} />
<View key={i} style={styles.nested} accessible accessibilityRole="none">
<View style={styles.nested} />
</View>
))}
</View>
);
Expand Down
Loading