New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performances #470
Closed
Closed
Improve performances #470
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
@@ -1,14 +1,3 @@ | ||
.DS_Store | ||
.prettierrc | ||
.nyc_output | ||
.travis.yml | ||
coverage | ||
coverage.lcov | ||
bench | ||
docs | ||
src | ||
examples | ||
babel.config.js | ||
test | ||
CONTRIBUTING.md | ||
CODE_OF_CONDUCT.md | ||
/* | ||
!/dist/**/*.js | ||
!/props.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,16 @@ | ||
module.exports = { | ||
env: { | ||
test: { | ||
presets: [ | ||
[ '@babel/env', { loose: true } ], | ||
'@babel/react' | ||
], | ||
plugins: [ | ||
'@babel/transform-runtime' | ||
] | ||
}, | ||
cjs: { | ||
presets: [ | ||
[ '@babel/env', { loose: true } ] | ||
], | ||
plugins: [ | ||
'@babel/transform-runtime' | ||
] | ||
}, | ||
esm: { | ||
presets: [ | ||
[ '@babel/env', { loose: true, modules: false } ] | ||
], | ||
plugins: [ | ||
['@babel/transform-runtime', { useESModules: true }] | ||
] | ||
}, | ||
module.exports = function getConfig(api) { | ||
const isRollup = api.caller( | ||
caller => caller && caller.name === 'rollup-plugin-babel' | ||
) | ||
if (!isRollup) | ||
return { | ||
presets: [['@babel/preset-env', { loose: true }], '@babel/react'], | ||
} | ||
return { | ||
presets: [['@babel/preset-env', { loose: true, modules: false }]], | ||
plugins: [ | ||
'babel-plugin-annotate-pure-calls', | ||
['@babel/transform-runtime', { useESModules: true }], | ||
], | ||
} | ||
} |
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,40 @@ | ||
/* eslint-disable no-console, import/no-unresolved */ | ||
const Benchmark = require('benchmark') | ||
|
||
const libs = [ | ||
{ | ||
name: 'actual', | ||
module: require('../dist/styled-system.cjs'), | ||
}, | ||
{ | ||
name: 'v4', | ||
module: require('./v4.1.0'), | ||
}, | ||
].map(({ name, module: { compose, fontSize, space } }) => { | ||
const system = compose( | ||
fontSize, | ||
space | ||
) | ||
const run = () => system({ p: [10, 20], mt: 10, m: '20px', fontSize: 10 }) | ||
return { name, run } | ||
}) | ||
|
||
const suite = new Benchmark.Suite() | ||
|
||
console.log('Initial run...') | ||
|
||
libs.forEach(lib => { | ||
console.log(lib.name, lib.run()) | ||
suite.add(lib.name, lib.run) | ||
}) | ||
|
||
console.log('Run suite...') | ||
|
||
suite | ||
.on('cycle', event => { | ||
console.log(String(event.target)) | ||
}) | ||
.on('complete', function onComplete() { | ||
console.log(`Fastest is ${this.filter('fastest').map('name')}`) | ||
}) | ||
.run({ async: true }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing is missing here. cjs bundle will get esm imports.
Here I added transform-runtime in place and didin't use it for tests and benchmarks. babel runtime is just an optimisation.
https://github.com/istarkov/rifm/blob/master/rollup.config.js#L19