Skip to content
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
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 3 additions & 14 deletions .npmignore
@@ -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
21 changes: 21 additions & 0 deletions .size-snapshot.json
@@ -0,0 +1,21 @@
{
"dist/styled-system.cjs.js": {
"bundled": 18770,
"minified": 11412,
"gzipped": 3166
},
"dist/styled-system.esm.js": {
"bundled": 16584,
"minified": 9464,
"gzipped": 2771,
"treeshaked": {
"rollup": {
"code": 79,
"import_statements": 44
},
"webpack": {
"code": 1112
}
}
}
}
26 changes: 2 additions & 24 deletions babel.config.js
@@ -1,29 +1,7 @@
module.exports = {
env: {
test: {
presets: [
[ '@babel/env', { loose: true } ],
'@babel/react'
],
plugins: [
'@babel/transform-runtime'
]
presets: [['@babel/preset-env', { loose: true }], '@babel/react'],
},
cjs: {
presets: [
[ '@babel/env', { loose: true } ]
],
plugins: [
'@babel/transform-runtime'
]
},
esm: {
presets: [
[ '@babel/env', { loose: true, modules: false } ]
],
plugins: [
['@babel/transform-runtime', { useESModules: true }]
]
},
}
},
}
40 changes: 40 additions & 0 deletions benchmarks/index.js
@@ -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 })