Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .changeset/smooth-baths-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@callstack/reassure-measure": minor
"reassure-test-app": minor
"reassure": minor
---

feat: disable owner stacks to improve render duration stability
4 changes: 4 additions & 0 deletions docusaurus/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Custom wrapper for the RNTL/RTL's `render` function responsible for rendering th
measuring its performance and writing results to the output file. You can use optional `options` object allows customizing aspects
of the testing.

During render measurements, Reassure disables React owner-stack collection to reduce React test overhead and improve measurement stability.
Set `RTC_SKIP_DISABLE_OWNER_STACKS` to any truthy value to skip this behavior and leave owner stacks enabled.

```ts
async function measureRenders(
ui: React.ReactElement,
Expand Down Expand Up @@ -234,6 +237,7 @@ The `reassure` CLI can be parametrized using available environmental variables:

- `TEST_RUNNER_PATH`: an alternative path for your test runner. Defaults to `'node_modules/.bin/jest'` or on Windows `'node_modules/jest/bin/jest'`
- `TEST_RUNNER_ARGS`: a set of arguments fed to the runner. Defaults to `'--runInBand --testMatch "**/__perf__/**/*.[jt]s?(x)", "**/*.(perf|perf-test).[jt]s?(x)"`
- `RTC_SKIP_DISABLE_OWNER_STACKS`: set to any truthy value to skip disabling React owner-stack collection during render measurements

Example:

Expand Down
3 changes: 2 additions & 1 deletion packages/measure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"dependencies": {
"@callstack/reassure-logger": "1.5.1",
"mathjs": "^15.2.0",
"pretty-format": "^30.4.1"
"pretty-format": "^30.4.1",
"react-test-config": "^0.3.0"
},
"devDependencies": {
"@babel/core": "^7.29.7",
Expand Down
2 changes: 2 additions & 0 deletions packages/measure/src/measure-renders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import * as logger from '@callstack/reassure-logger';
import { config } from './config';
import { RunResult, processRunResults } from './measure-helpers';
import { disableOwnerStacksIfNeeded } from './owner-stacks';
import { showFlagsOutputIfNeeded, writeTestStats } from './output';
import { applyRenderPolyfills, revertRenderPolyfills } from './polyfills';
import { ElementJsonTree, detectRedundantUpdates } from './redundant-renders';
Expand Down Expand Up @@ -63,6 +64,7 @@ async function measureRendersInternal(
const { render, cleanup } = resolveTestingLibrary();
const testingLibrary = getTestingLibrary();

disableOwnerStacksIfNeeded();
showFlagsOutputIfNeeded();
applyRenderPolyfills();

Expand Down
12 changes: 12 additions & 0 deletions packages/measure/src/owner-stacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { disableOwnerStacks } from 'react-test-config';

let hasDisabledOwnerStacks = false;

export function disableOwnerStacksIfNeeded() {
if (hasDisabledOwnerStacks) {
return;
}

disableOwnerStacks();
hasDisabledOwnerStacks = true;
}
3 changes: 0 additions & 3 deletions test-apps/native/jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { configure } from 'reassure';
import { disableOwnerStacks } from 'react-test-config';

configure({
testingLibrary: 'react-native',
verbose: true,
});

disableOwnerStacks();
1 change: 0 additions & 1 deletion test-apps/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"eslint-plugin-oxfmt": "^0.10.0",
"jest": "^30.4.2",
"oxfmt": "^0.54.0",
"react-test-config": "^0.3.0",
"reassure": "workspace:^",
"test-renderer": "1.2.0",
"typescript": "^6.0.3"
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ __metadata:
react: "npm:19.2.3"
react-native: "npm:0.85.3"
react-native-builder-bob: "npm:^0.41.0"
react-test-config: "npm:^0.3.0"
strip-ansi: "npm:^6.0.1"
test-renderer: "npm:1.2.0"
typescript: "npm:^6.0.3"
Expand Down Expand Up @@ -10582,7 +10583,6 @@ __metadata:
oxfmt: "npm:^0.54.0"
react: "npm:19.2.3"
react-native: "npm:0.85.3"
react-test-config: "npm:^0.3.0"
reassure: "workspace:^"
test-renderer: "npm:1.2.0"
typescript: "npm:^6.0.3"
Expand Down
Loading