babylon_performance

Parses various fixtures and outputs parse times over various iterations

Run

git clone git@github.com:babel/babylon_performance.git
git clone git@github.com:babel/babylon.git
npm install
npm t

Performance PRs

Check the performance label in the babylon repo for some examples.

Perf Tips

Microbenchmarks don't help that much, should test the real thing? (Also I don't know what I'm talking about)

  • Caching, Set.has vs. [].indexOf(val), hoisting, GC issues
  • Make sure node shapes are the same (should be automated) babel/notes#9

Checking Performance

Install/Use Node 8

Node 8 has a weird UI bug with Profiling atm, so switch to Node 6/7? https://twitter.com/drewml/status/881564816208527364

nvm use 8
node -v

Install NIM

https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en

It's a chrome Extension that helps automatically open the devtools when running --inspect

Using node --prof

https://nodejs.org/en/docs/guides/simple-profiling/

node --prof script.js
node --prof-process isolate*.log
# node --prof-process isolate*.log > out.txt

With babylon:

node --prof ./node_modules/babylon/bin/babylon.js fixtures/ember.debug.js
node --prof-process isolate*.log

Use node --trace-opt

node --trace-opt script.js | grep myFunc
node --trace-opt ./node_modules/babylon/bin/babylon.js fixtures/ember.debug.js

Use node --inspect-brk

https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27

Point node to the babylon script and pass in a file to parse

In this case I am running node in babylon/ with babylon_performance/ in sibling folder

cd babylon

# node --inspect-brk script.js
node --inspect-brk ./bin/babylon.js ../babylon_performance/fixtures/angular.js

If you have install NIM, it should open up chrome and show this view: (if not you can open the url shown in the console yourself)

Imgur

Then click on the "Profiler" Tab

Imgur

Then click "Start"

Imgur

Wait a little bit and click "Stop", and you will be redirect to this screen

Imgur

Some Links