-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6856ade
Showing
124 changed files
with
5,528 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@tamagui/bench-components", | ||
"version": "1.0.0-alpha.8", | ||
"private": true, | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"source": "src/index.ts", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"typings": "types.d.ts", | ||
"module:jsx": "_jsx", | ||
"files": [ | ||
"_jsx", | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "tamagui-build --jsx", | ||
"watch": "tamagui-build --jsx --watch" | ||
}, | ||
"dependencies": { | ||
"@tamagui/core": "^1.0.0-alpha.8", | ||
"@tamagui/fake-react-native": "^1.0.0-alpha.2", | ||
"@tamagui/helpers": "^1.0.0-alpha.8" | ||
}, | ||
"peerDependencies": { | ||
"react-native-web": "*" | ||
}, | ||
"devDependencies": { | ||
"@tamagui/build": "^1.0.0-alpha.8", | ||
"@types/node": "^16.11.9", | ||
"@types/react": "^17.0.35" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { styled } from '@tamagui/core' | ||
|
||
import { View } from './View' | ||
|
||
export const Box = styled(View, { | ||
alignSelf: 'flex-start', | ||
backgroundColor: 'transparent', | ||
|
||
variants: { | ||
color: { | ||
0: { | ||
backgroundColor: '#14171A', | ||
}, | ||
1: { | ||
backgroundColor: '#AAB8C2', | ||
}, | ||
2: { | ||
backgroundColor: '#E6ECF0', | ||
}, | ||
3: { | ||
backgroundColor: '#FFAD1F', | ||
}, | ||
4: { | ||
backgroundColor: '#F45D22', | ||
}, | ||
5: { | ||
backgroundColor: '#E0245E', | ||
}, | ||
}, | ||
|
||
layout: { | ||
column: { | ||
flexDirection: 'column', | ||
}, | ||
row: { | ||
flexDirection: 'row', | ||
}, | ||
}, | ||
|
||
outer: { | ||
true: { | ||
padding: '4px', | ||
}, | ||
}, | ||
|
||
fixed: { | ||
true: { | ||
width: '6px', | ||
height: '6px', | ||
}, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Stack, styled } from '@tamagui/core' | ||
|
||
export const Button = styled(Stack, { | ||
tag: 'button', | ||
alignItems: 'center', | ||
flexShrink: 0, | ||
justifyContent: 'center', | ||
backgroundColor: 'white', | ||
borderColor: '#999', | ||
borderWidth: 1, | ||
borderRadius: 3, | ||
height: 25, | ||
paddingLeft: 10, | ||
paddingRight: 10, | ||
|
||
variants: { | ||
disabled: { | ||
true: { | ||
backgroundColor: 'gray', | ||
// shadowColor: 'inset 0 0 0 1px gray', | ||
shadowColor: 'gray', | ||
pointerEvents: 'none', | ||
}, | ||
}, | ||
|
||
active: { | ||
true: { | ||
backgroundColor: 'gray', | ||
}, | ||
}, | ||
|
||
size: { | ||
1: { | ||
borderRadius: '2', | ||
height: 25, | ||
paddingHorizontal: 10, | ||
}, | ||
2: { | ||
borderRadius: '3', | ||
height: 35, | ||
paddingHorizontal: 15, | ||
}, | ||
}, | ||
|
||
blue: { | ||
true: { | ||
backgroundColor: 'blue', | ||
borderColor: 'gray', | ||
}, | ||
}, | ||
red: { | ||
true: { | ||
backgroundColor: 'red', | ||
borderColor: 'gray', | ||
}, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { styled } from '@tamagui/core' | ||
|
||
import { View } from './View' | ||
|
||
export const Dot = styled(View, { | ||
position: 'absolute', | ||
cursor: 'pointer', | ||
width: '0', | ||
height: '0', | ||
borderColor: 'transparent', | ||
borderStyle: 'solid', | ||
borderTopWidth: 0, | ||
transform: 'translate(50%, 50%)', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Stack, styled } from '@tamagui/core' | ||
|
||
export const View = styled(Stack, { | ||
alignItems: 'stretch', | ||
display: 'flex', | ||
flexBasis: 'auto', | ||
flexDirection: 'column', | ||
flexShrink: 0, | ||
position: 'relative', | ||
minHeight: '0', | ||
minWidth: '0', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { Button } from './Button' | ||
export * from '@tamagui/core' | ||
export * from './Dot' | ||
export * from './View' | ||
export * from './Box' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "preserve", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
.pnp | ||
.pnp.js | ||
|
||
# testing | ||
coverage | ||
|
||
# next.js | ||
.next/ | ||
out/ | ||
.now | ||
|
||
# production | ||
build | ||
lib | ||
dist | ||
storybook-static | ||
.rpt2_cache | ||
.cache | ||
|
||
# misc | ||
.DS_Store | ||
.firebase | ||
.firebaserc | ||
*.tsbuildinfo | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
firebase-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
leaving these out of packages as they affect install time a ton. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import React from 'react' | ||
|
||
import { RunResult, TestInfo } from './TestRunner' | ||
|
||
type Result = Omit<RunResult, 'N'> | ||
type ResultKey = keyof Result | ||
|
||
const calculateAverage = ( | ||
results: Record<number, Result>, | ||
key: ResultKey, | ||
numberOfRuns: number | ||
) => { | ||
let total = 0 | ||
;[...Array(numberOfRuns)].forEach((_, index) => (total = total + results[index][key])) | ||
return total / numberOfRuns | ||
} | ||
|
||
export const TestResults = ({ testInfo }: { testInfo: TestInfo }) => { | ||
const averageInfo: Result = { | ||
firstIteration: calculateAverage(testInfo.results, 'firstIteration', testInfo.numberOfRuns), | ||
lastIteration: calculateAverage(testInfo.results, 'lastIteration', testInfo.numberOfRuns), | ||
fastestIteration: calculateAverage(testInfo.results, 'fastestIteration', testInfo.numberOfRuns), | ||
slowestIteration: calculateAverage(testInfo.results, 'slowestIteration', testInfo.numberOfRuns), | ||
meanIteration: calculateAverage(testInfo.results, 'meanIteration', testInfo.numberOfRuns), | ||
medianIteration: calculateAverage(testInfo.results, 'medianIteration', testInfo.numberOfRuns), | ||
variance: calculateAverage(testInfo.results, 'variance', testInfo.numberOfRuns), | ||
} | ||
|
||
return ( | ||
<div> | ||
<style | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
th, td { | ||
padding: 10px; | ||
} | ||
ul { | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
} | ||
li { | ||
padding: 5px; | ||
} | ||
h3 { | ||
margin-bottom: 5px; | ||
} | ||
`, | ||
}} | ||
/> | ||
|
||
<div>N: {testInfo.N}</div> | ||
<div>Ran test: {testInfo.numberOfRuns} times</div> | ||
|
||
<ul> | ||
<h3>Instructions</h3> | ||
<li>Check across tests for drastic differences, should be near identical.</li> | ||
<li>Take first test for most accurate "cold start" results.</li> | ||
</ul> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th /> | ||
<th>First run</th> | ||
<th>Last run</th> | ||
<th>Mean</th> | ||
<th>Median</th> | ||
<th>Fastest</th> | ||
<th>Slowest</th> | ||
<th>SD</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{[...Array(testInfo.numberOfRuns)].map((_val, runIndex) => { | ||
return ( | ||
<tr key={runIndex}> | ||
<th>Test {runIndex + 1}</th> | ||
<ResultCells result={testInfo.results[runIndex]} /> | ||
</tr> | ||
) | ||
})} | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<th>Average</th> | ||
<ResultCells result={averageInfo} /> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
|
||
<hr /> | ||
|
||
<ul> | ||
<li>Last run should be about the same or faster than the first run</li> | ||
<li> | ||
Standard deviation should only be a few milliseconds or something is causing renders to be | ||
wildly different | ||
</li> | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
||
function ResultCells({ result }) { | ||
const { | ||
firstIteration, | ||
lastIteration, | ||
meanIteration, | ||
medianIteration, | ||
variance, | ||
slowestIteration, | ||
fastestIteration, | ||
} = result | ||
|
||
const alertLastRender = lastIteration > firstIteration * 1.1 ? { color: 'orange' } : undefined | ||
return ( | ||
<> | ||
<td>{firstIteration.toFixed(6)}</td> | ||
<td style={alertLastRender}>{lastIteration.toFixed(6)}</td> | ||
<td>{meanIteration.toFixed(6)}</td> | ||
<td>{medianIteration.toFixed(6)}</td> | ||
<td>{fastestIteration.toFixed(6)}</td> | ||
<td>{slowestIteration.toFixed(6)}</td> | ||
<td>{Math.sqrt(variance).toFixed(6)}</td> | ||
</> | ||
) | ||
} |
Oops, something went wrong.