Skip to content

Commit ce4ce1e

Browse files
committed
Add perf test component
1 parent 8fd4da4 commit ce4ce1e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

example/src/PerfTest.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { useMemo } from 'react';
2+
import { Stack } from './components';
3+
import { styled } from './styles';
4+
5+
let measured = false;
6+
7+
export default function PerfTest() {
8+
const start = useMemo(() => new Date(), []);
9+
10+
return (
11+
<Wrapper
12+
onLayout={() => {
13+
if (!measured) {
14+
measured = true;
15+
console.log(
16+
`Time taken: ${new Date().getTime() - start.getTime()} ms`
17+
);
18+
}
19+
}}
20+
>
21+
<Content>
22+
<Stack axis="y" space="4">
23+
{Array.from({ length: 1000 }).map((_, i) => (
24+
<Box key={i}>
25+
<BoxText>{i + 1}</BoxText>
26+
</Box>
27+
))}
28+
</Stack>
29+
</Content>
30+
</Wrapper>
31+
);
32+
}
33+
34+
const Wrapper = styled('SafeAreaView', {
35+
flex: 1,
36+
backgroundColor: '$background',
37+
});
38+
39+
const Content = styled('ScrollView', {
40+
flex: 1,
41+
}).attrs((p) => ({
42+
contentContainerStyle: {
43+
padding: p.theme.space[2],
44+
},
45+
}));
46+
47+
const Box = styled('View', {
48+
minHeight: 100,
49+
backgroundColor: '$primaryMuted',
50+
flexCenter: 'row',
51+
borderRadius: '$md',
52+
});
53+
54+
const BoxText = styled('Text', {
55+
color: '$primaryText',
56+
});

0 commit comments

Comments
 (0)