Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of pretty-format #16

Merged
merged 5 commits into from
Jul 2, 2016
Merged

Improve performance of pretty-format #16

merged 5 commits into from
Jul 2, 2016

Conversation

jamiebuilds
Copy link
Owner

This doesn't support everything yet, but it is a pretty big restructuring that will allow it to work much much faster.

See comparison: https://gist.github.com/thejameskyle/fce69285d4682923061bf5f83461cc7b

cc @cpojer

@cpojer
Copy link
Contributor

cpojer commented Jun 30, 2016

Nice work!

@jamiebuilds
Copy link
Owner Author

jamiebuilds commented Jul 1, 2016

Hmm– testing with really large objects this is actually quite a bit slower. 9930672ns vs 6715812ns

@jamiebuilds
Copy link
Owner Author

Never mind, I realized I've been doing something stupid and measuring this completely wrong. Here is the corrected comparison: https://gist.github.com/thejameskyle/f8b50bf559360549326b52f3bb323d5d

@cpojer
Copy link
Contributor

cpojer commented Jul 1, 2016

Not sure I can trust you again after this.

@jamiebuilds
Copy link
Owner Author

Not sure I can trust you again after this.

Hey I improved the performance without even having real metrics to guide me. That must count for something

@jamiebuilds
Copy link
Owner Author

Okay, got everything working again and here are the new perf results: https://gist.github.com/thejameskyle/2b04ffe4941aafa8f970de077843a8fd

@jamiebuilds jamiebuilds changed the title [WIP] Improve performance of pretty-format Improve performance of pretty-format Jul 1, 2016
@cpojer cpojer merged commit 304363d into master Jul 2, 2016
@cpojer
Copy link
Contributor

cpojer commented Jul 2, 2016

I love it. Fantastic work, @thejameskyle.

@jamiebuilds jamiebuilds deleted the perf branch July 2, 2016 20:37
@jdalton
Copy link

jdalton commented Jul 6, 2016

Woot!

Heads up! There is some handy process.binding('util') helpers for isTypedArray, isMap, isSet, etc. that are ~2x faster than that of traditional Object.prototype.toString.call checks (Lodash will start using them). Also, engines have made Array.isArray pretty fast.

@jamiebuilds
Copy link
Owner Author

nice, thanks

@jdalton
Copy link

jdalton commented Jul 7, 2016

No prob. I've opened an issue on Node to propose exposing more of them ⚡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants