-
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
1 parent
fe53111
commit 1faed1e
Showing
18 changed files
with
378 additions
and
302 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
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 |
---|---|---|
@@ -1 +1 @@ | ||
18.17.1 | ||
20 |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
"presets": ["module:metro-react-native-babel-preset"], | ||
presets: ['module:metro-react-native-babel-preset'], | ||
} |
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
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 |
---|---|---|
@@ -1,82 +1,78 @@ | ||
import React from 'react'; | ||
import React from 'react' | ||
|
||
import { create as r } from 'react-test-renderer'; | ||
import { create as r } from 'react-test-renderer' | ||
|
||
import fs from 'fs'; | ||
import fs from 'fs' | ||
|
||
import Benchmark from 'benchmark'; | ||
import Benchmark from 'benchmark' | ||
|
||
import styled from 'styled-components/native' | ||
import emotion from '@emotion/native'; | ||
import emotion from '@emotion/native' | ||
|
||
import shakl from '../src/rn'; | ||
|
||
const suite = new Benchmark.Suite(); | ||
import shakl from '../src/rn' | ||
|
||
const suite = new Benchmark.Suite() | ||
|
||
suite.add('Shakl', () => { | ||
const Foo = shakl.View({ padding: 10 }); | ||
r(<Foo />); | ||
}); | ||
const Foo = shakl.View({ padding: 10 }) | ||
r(<Foo />) | ||
}) | ||
|
||
suite.add('Emotion', () => { | ||
const Foo = emotion.View`padding: 10px` | ||
r(<Foo />) | ||
}); | ||
}) | ||
|
||
suite.add('Styled Components', () => { | ||
const Foo = styled.View`padding: 10px` | ||
const Foo = styled.View` | ||
padding: 10px; | ||
` | ||
r(<Foo />) | ||
}); | ||
}) | ||
|
||
const results = {}; | ||
const results = {} | ||
|
||
afterAll(() => { | ||
const result = `const results = ${JSON.stringify(results, null, 2)};\n` | ||
fs.writeFileSync(`${__dirname}/results.js`, result) | ||
}) | ||
|
||
it('runs', () => { | ||
suite | ||
.on('complete', e => { | ||
.on('complete', (e) => { | ||
const { | ||
stats: { mean: first }, | ||
name: firstFunc | ||
} = e.currentTarget[0]; | ||
name: firstFunc, | ||
} = e.currentTarget[0] | ||
|
||
let min = first; | ||
let max = first; | ||
let min = first | ||
let max = first | ||
|
||
let minFunc = firstFunc; | ||
let maxFunc = firstFunc; | ||
let minFunc = firstFunc | ||
|
||
let output = ''; | ||
let output = '' | ||
|
||
e.currentTarget.forEach(({ stats: { mean }, name }) => { | ||
if (mean < min) { | ||
min = mean; | ||
minFunc = name; | ||
min = mean | ||
minFunc = name | ||
} | ||
|
||
if (mean > max) { | ||
max = mean; | ||
maxFunc = name; | ||
max = mean | ||
} | ||
|
||
const result = mean * 1000; | ||
const result = mean * 1000 | ||
|
||
results[name] = result; | ||
results[name] = result | ||
|
||
output += `${name} averaged ${result} ms\n`; | ||
}); | ||
output += `${name} averaged ${result} ms\n` | ||
}) | ||
|
||
output += `\n${minFunc} is min, ${min * 1000} ms\n`; | ||
output += `diff is ${(((max - min) / max) * 100).toFixed(2)}%\n`; | ||
output += `\n${minFunc} is min, ${min * 1000} ms\n` | ||
output += `diff is ${(((max - min) / max) * 100).toFixed(2)}%\n` | ||
|
||
console.log(output); | ||
console.log(output) | ||
}) | ||
.run(); | ||
}); | ||
|
||
afterAll(() => { | ||
const result = `const results = ${JSON.stringify(results, null, 2)};\n` | ||
fs.writeFileSync( | ||
`${__dirname}/results.js`, | ||
result | ||
); | ||
}); | ||
.run() | ||
}) |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
const results = { | ||
"Shakl": 0.02981142424152011, | ||
"Emotion": 0.03720938087122486, | ||
"Styled Components": 0.04661131669539433 | ||
}; | ||
Shakl: 0.029_811_424_241_520_11, | ||
Emotion: 0.037_209_380_871_224_86, | ||
'Styled Components': 0.046_611_316_695_394_33, | ||
} |
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,25 @@ | ||
import { createTypescriptReactBabelPreset } from '@exodus/eslint-config-exodus' | ||
|
||
const config = [ | ||
{ ignores: ['lib', 'node_modules'] }, | ||
createTypescriptReactBabelPreset({ project: ['./tsconfig.test.json'] }), | ||
{ | ||
settings: { | ||
'import/ignore': ['node_modules/react-native/index\\.js$'], | ||
}, | ||
}, | ||
{ | ||
files: ['jest.config.js', 'jest-setup.js'], | ||
rules: { | ||
'import/no-extraneous-dependencies': ['error', { devDependencies: true }], | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.type-test.ts{x,}'], | ||
rules: { | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
}, | ||
}, | ||
].flat() | ||
|
||
export default config |
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 |
---|---|---|
@@ -1 +1 @@ | ||
require('react-native-reanimated').setUpTests(); | ||
require('react-native-reanimated').setUpTests() |
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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
module.exports = { | ||
'collectCoverageFrom': [ | ||
'src/**/*.js' | ||
collectCoverageFrom: ['src/**/*.js'], | ||
verbose: true, | ||
preset: 'react-native', | ||
transformIgnorePatterns: [ | ||
'/node_modules/(?!(@react-native|react-native|react-native-reanimated)/).*/', | ||
], | ||
'verbose': true, | ||
'preset': 'react-native', | ||
'transformIgnorePatterns': [ | ||
'/node_modules/(?!(@react-native|react-native|react-native-reanimated)/).*/' | ||
], | ||
'setupFilesAfterEnv': [ | ||
'./jest-setup.js' | ||
] | ||
setupFilesAfterEnv: ['./jest-setup.js'], | ||
} |
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
Oops, something went wrong.