power-assert-js / babel-plugin-espower

Babel plugin for power-assert
MIT License
93 stars 6 forks source link

Use prototype based Recorder for performance boost. #12

Closed jamestalmage closed 8 years ago

jamestalmage commented 8 years ago

The current method of creating a PowerAssertRecorder prevents some optimizations by the V8 compiler.

Specifically, it creates many extra closure contexts, and prevents the use of hidden classes.

My test suite was seeing roughly a 5% boost.

jamestalmage commented 8 years ago

@twada -

The function.toString() seems it to make it easier to edit the helper template. The only issue is it prevents coverage using nyc because of this. It really only seems to be an issue while I was trying to npm link this into ava (the solution was explicitly excluding **/babel-plugin-espower/** in my nyc config).

An alternate solution (should you ever want to add code coverage to this project), would be to move the helper to it's own file and just use fs.readFileSync.

twada commented 8 years ago

@jamestalmage Nice optimization! Just out of curiosity, is function.toString() portable enough?

fs.readFileSync approach looks better to me.

jamestalmage commented 8 years ago

fs.readFileSync added :smile:

jamestalmage commented 8 years ago

@twada - should be good to go

twada commented 8 years ago

@jamestalmage Looks good to me. I'm going to merge and cut a new release.

twada commented 8 years ago

@jamestalmage babel-plugin-espower 2.1.1 is out. Thanks!