Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions benchmark/babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {readFileSync} from 'fs'
import {resolve} from 'path'
import Benchmark from 'benchmark'
import {transform as babel} from 'babel-core'

import plugin from '../src/babel'

const read = path => readFileSync(resolve(__dirname, path), 'utf8')
const fixture = read('./fixtures/babel.js')

module.exports = new Benchmark({
name: 'Babel transform',
minSamples: 500,
fn: () => {
babel(fixture, {
babelrc: false,
plugins: [plugin]
})
}
})
38 changes: 38 additions & 0 deletions benchmark/fixtures/babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const Test1 = () => (
<div>
<span>test</span>
<span>test</span>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p>
<p><span></span></p><p><span></span></p><p><span></span></p>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p>
<p><span></span></p><p><span></span></p><p><span></span></p>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p>
<p><span></span></p><p><span></span></p><p><span></span></p>
<Component />
<style jsx>{`
span { color: red; }
p { color: red; }
`}</style>
</div>
)

export const Test2 = () => <span>test</span>

export default class {
render() {
return (
<div>
<p>test</p>
<style jsx>{`
p { color: red; }
`}</style>
<style jsx>{`
p { color: red; }
`}</style>
<style jsx>{`
p { color: red; }
`}</style>
</div>
)
}
}
11 changes: 10 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import gulp from 'gulp'
import babel from 'gulp-babel'
import {transformFile} from 'babel-core'
import size from 'human-size'
import benchmark from 'gulp-benchmark'

gulp.task('transpile', () => {
gulp.src('src/**/*.js')
Expand Down Expand Up @@ -41,5 +42,13 @@ gulp.task('runtime-size', async () => {
}
})

gulp.task('watch', () => gulp.watch('src/*', ['transpile']))
gulp.task('benchmark', () => {
gulp.src('*.js', {read: false, cwd: './benchmark'})
.pipe(babel())
.pipe(benchmark())
})
gulp.task('watch', () => {
gulp.watch('src/*', ['transpile'])
gulp.watch('benchmark/*.js', ['benchmark'])
})
gulp.task('default', ['transpile', 'watch'])
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
"babel-preset-react": "^6.16.0",
"babel-preset-stage-3": "^6.16.0",
"babel-register": "^6.18.0",
"benchmark": "^2.1.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-benchmark": "^1.1.1",
"human-size": "^1.1.0",
"mz": "^2.6.0",
"react": "^15.4.1",
Expand Down