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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AsyncComponent } from './AsyncComponent';

jest.setTimeout(600_000);

test('RN CLI - AsyncComponent 10 runs', async () => {
test('RN CLI - AsyncComponent (10 runs)', async () => {
const scenario = async () => {
const button = screen.getByText('Action');

Expand All @@ -18,7 +18,7 @@ test('RN CLI - AsyncComponent 10 runs', async () => {
await measureRenders(<AsyncComponent />, { scenario, runs: 10 });
});

test('RN CLI - AsyncComponent 50 runs', async () => {
test('RN CLI - AsyncComponent (50 runs)', async () => {
const scenario = async () => {
const button = screen.getByText('Action');

Expand Down
4 changes: 2 additions & 2 deletions examples/native-cli/src/AsyncComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { View, Text, Pressable } from 'react-native';
import { SlowList } from './SlowList';
import { TestList } from './TestList';

export function AsyncComponent() {
const [count, setCount] = React.useState(0);
Expand All @@ -17,7 +17,7 @@ export function AsyncComponent() {

<Text>Count: {count}</Text>

<SlowList count={200} />
<TestList count={200} />
</View>
);
}
10 changes: 0 additions & 10 deletions examples/native-cli/src/SlowList.perf-test.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions examples/native-cli/src/SlowList.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions examples/native-cli/src/TestList.perf.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react';
import { jest, test } from '@jest/globals';
import { measureRenders } from 'reassure';
import { TestList } from './TestList';

jest.setTimeout(60_000);

test('RN CLI - TestList (100 items)', async () => {
await measureRenders(<TestList count={100} />);
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react-native';
import { expect, test } from '@jest/globals';
import { SlowList } from './SlowList';
import { TestList } from './TestList';

test('SlowList', () => {
render(<SlowList count={10} />);
test('TestList', () => {
render(<TestList count={10} />);

const items = screen.getAllByText(/Item/i);
expect(items).toHaveLength(10);
Expand Down
36 changes: 36 additions & 0 deletions examples/native-cli/src/TestList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as React from 'react';
import { View, Text } from 'react-native';

interface TestListProps {
count: number;
}

export const TestList = ({ count }: TestListProps) => {
const data = Array.from({ length: count }, (_, index) => index);

return (
<View>
{data.map(item => (
<ListItem key={item} title={`Item ${item}`} />
))}
</View>
);
};

interface ListItemProps {
title: string;
}

const ListItem = ({ title }: ListItemProps) => {
// Uncomment to introduce a performance issue
// const [, forceRender] = React.useState<{}>();
// React.useEffect(() => {
// forceRender({});
// }, [title]);

return (
<View>
<Text>{title}</Text>
</View>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AsyncComponent } from './AsyncComponent';

jest.setTimeout(600_000);

test('RN Expo - AsyncComponent 10 runs', async () => {
test('React Native - Expo - AsyncComponent (10 runs)', async () => {
const scenario = async () => {
const button = screen.getByText('Action');

Expand All @@ -18,7 +18,7 @@ test('RN Expo - AsyncComponent 10 runs', async () => {
await measureRenders(<AsyncComponent />, { scenario, runs: 10 });
});

test('RN Expo - AsyncComponent 50 runs', async () => {
test('React Native - Expo - AsyncComponent (50 runs)', async () => {
const scenario = async () => {
const button = screen.getByText('Action');

Expand Down
6 changes: 3 additions & 3 deletions examples/native-expo/src/AsyncComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import { View, Text, Pressable } from 'react-native';
import { SlowList } from './SlowList';
import { TestList } from './TestList';

export function AsyncComponent() {
const [count, setCount] = React.useState(0);

const handlePress = () => {
setTimeout(() => setCount(c => c + 1), 10);
setTimeout(() => setCount((c) => c + 1), 10);
};

return (
Expand All @@ -17,7 +17,7 @@ export function AsyncComponent() {

<Text>Count: {count}</Text>

<SlowList count={200} />
<TestList count={200} />
</View>
);
}
10 changes: 0 additions & 10 deletions examples/native-expo/src/SlowList.perf-test.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions examples/native-expo/src/SlowList.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions examples/native-expo/src/TestList.perf.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react';
import { jest, test } from '@jest/globals';
import { measureRenders } from 'reassure';
import { TestList } from './TestList';

jest.setTimeout(60_000);

test('React Native - Expo - TestList (100 items)', async () => {
await measureRenders(<TestList count={100} />, { runs: 10 });
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react-native';
import { SlowList } from './SlowList';
import { TestList } from './TestList';

test('SlowList', () => {
render(<SlowList count={10} />);
test('TestList', () => {
render(<TestList count={10} />);

const items = screen.getAllByText(/Item/i);
expect(items).toHaveLength(10);
Expand Down
36 changes: 36 additions & 0 deletions examples/native-expo/src/TestList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as React from 'react';
import { View, Text } from 'react-native';

interface TestListProps {
count: number;
}

export const TestList = ({ count }: TestListProps) => {
const data = Array.from({ length: count }, (_, index) => index);

return (
<View>
{data.map((item) => (
<ListItem key={item} title={`Item ${item}`} />
))}
</View>
);
};

interface ListItemProps {
title: string;
}

const ListItem = ({ title }: ListItemProps) => {
// Uncomment to introduce a performance issue
// const [, forceRender] = React.useState<{}>();
// React.useEffect(() => {
// forceRender({});
// }, [title]);

return (
<View>
<Text>{title}</Text>
</View>
);
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// @ts-expect-error Needed for Jest testing
import * as React from 'react';
import { fireEvent, screen } from '@testing-library/react';
import { measureRenders } from 'reassure';
import { AsyncComponent } from './AsyncComponent';

jest.setTimeout(60_000);

test('Web Next.js - AsyncComponent 10 runs', async () => {
test('Web Next.js - AsyncComponent (10 runs)', async () => {
const scenario = async () => {
const button = screen.getByText('Action');

Expand All @@ -25,7 +24,7 @@ test('Web Next.js - AsyncComponent 10 runs', async () => {
await measureRenders(<AsyncComponent />, { scenario, runs: 10 });
});

test('Web Next.js - AsyncComponent 50 runs', async () => {
test('Web Next.js - AsyncComponent (50 runs)', async () => {
const scenario = async () => {
const button = screen.getByText('Action');

Expand Down
4 changes: 2 additions & 2 deletions examples/web-nextjs/src/components/AsyncComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { SlowList } from './SlowList';
import { TestList } from './TestList';

export function AsyncComponent() {
const [count, setCount] = React.useState(0);
Expand All @@ -13,7 +13,7 @@ export function AsyncComponent() {
<button onClick={handlePress}>Action</button>
<span>Count: {count}</span>

<SlowList count={200} />
<TestList count={200} />
</div>
);
}
10 changes: 0 additions & 10 deletions examples/web-nextjs/src/components/SlowList.perf-test.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions examples/web-nextjs/src/components/SlowList.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions examples/web-nextjs/src/components/TestList.perf.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @ts-expect-error Needed for Jest testing
import * as React from 'react';
import { measureRenders } from 'reassure';
import { TestList } from './TestList';

jest.setTimeout(60_000);

test('Web Next.js - TestList (100 items)', async () => {
await measureRenders(<TestList count={100} />, { runs: 10 });
});
Loading