browserify / detective

Find all calls to require() no matter how deeply nested using a proper walk of the AST
Other
414 stars 61 forks source link

replaced uglify-js with esprima #13

Closed matjaz closed 12 years ago

ghost commented 12 years ago

Do you have any figures about what this does to performance?

matjaz commented 12 years ago

I've benchmarked /w browserify.

detective /w uglify-js

total detective time 86519
total compile time 1582

detective /w esprima

total detective time 80951
total compile time 1580

So we can say it's faster around 5-10%.

ghost commented 12 years ago

I just revisited this using a much bigger file and a quick esprima parser I wrote and the performance improvement is much more noteworthy:

> var src = require('fs').readFileSync('./node_modules/jquery-browserify/lib/jquery.js'); var find = require('./esp').find; var t0 = Date.now(); var res = find(src); Date.now() - t0
333

> var src = require('fs').readFileSync('./node_modules/jquery-browserify/lib/jquery.js'); var find = require('./').find; var t0 = Date.now(); var res = find(src); Date.now() - t0
1283

Nearly a 4x speedup.

matjaz commented 12 years ago

Good to hear that. Esprima kicks ass.

ghost commented 12 years ago

The latest detective is now using esprima but I'm not seeing too much of a speedup in browserify since there's a lot of other caching going on that hides the performance gains. The browserify test suite does run a few seconds faster now at least.

ariya commented 12 years ago

+1

tonysung commented 12 years ago

+1