Created
February 4, 2016 20:21
-
-
Save forivall/d303673559be900526ce to your computer and use it in GitHub Desktop.
babel-generator-benchmark
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
var babylon = require('babylon'); | |
var babelGenerator = require('babel-generator'); | |
var code = require('fs').readFileSync('./node_modules/jquery/dist/jquery.js', 'utf-8'); | |
var ts, ast, results; | |
// babylon | |
ts = +new Date(); | |
ast = babylon.parse(code); | |
console.log('babylon', +new Date() - ts); | |
// babel | |
ts = +new Date(); | |
babelGenerator.default(ast, {}, ''); | |
console.log('babel generator (cold)', +new Date() - ts); | |
ts = +new Date(); | |
babelGenerator.default(ast, {}, ''); | |
console.log('babel generator (warm 1)', +new Date() - ts); | |
var total = 0 | |
for (var i = 100; i > 0; i--) { | |
ts = +new Date(); | |
babelGenerator.default(ast, {}, ''); | |
total += (+new Date() - ts); | |
} | |
console.log('babel generator (warm avg)', total / 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, i symlinked in the directories for requiring