Skip to content

Commit

Permalink
Add perf test component
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzasse committed Dec 7, 2022
1 parent 8fd4da4 commit ce4ce1e
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions example/src/PerfTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { useMemo } from 'react';
import { Stack } from './components';
import { styled } from './styles';

let measured = false;

export default function PerfTest() {
const start = useMemo(() => new Date(), []);

return (
<Wrapper
onLayout={() => {
if (!measured) {
measured = true;
console.log(
`Time taken: ${new Date().getTime() - start.getTime()} ms`
);
}
}}
>
<Content>
<Stack axis="y" space="4">
{Array.from({ length: 1000 }).map((_, i) => (
<Box key={i}>
<BoxText>{i + 1}</BoxText>
</Box>
))}
</Stack>
</Content>
</Wrapper>
);
}

const Wrapper = styled('SafeAreaView', {
flex: 1,
backgroundColor: '$background',
});

const Content = styled('ScrollView', {
flex: 1,
}).attrs((p) => ({
contentContainerStyle: {
padding: p.theme.space[2],
},
}));

const Box = styled('View', {
minHeight: 100,
backgroundColor: '$primaryMuted',
flexCenter: 'row',
borderRadius: '$md',
});

const BoxText = styled('Text', {
color: '$primaryText',
});

0 comments on commit ce4ce1e

Please sign in to comment.