Skip to content

Instantly share code, notes, and snippets.

@forivall
Created February 4, 2016 20:21
Show Gist options
  • Save forivall/d303673559be900526ce to your computer and use it in GitHub Desktop.
Save forivall/d303673559be900526ce to your computer and use it in GitHub Desktop.
babel-generator-benchmark
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);
@forivall
Copy link
Author

forivall commented Feb 4, 2016

FYI, i symlinked in the directories for requiring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment