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

Use fast-safe-stringify for perf and to support circular refs #35

Merged
merged 3 commits into from
Jun 12, 2018

Conversation

indexzero
Copy link
Member

While catching up with @davidmarkclements at JSConf I was reminding that fast-safe-stringify is a great piece of code we should use by default. This PR:

  • Uses fast-safe-stringify instead of JSON.stringify
  • Adds a test for circular JSON since bonus fast-safe-stringify also supports circular JSON refs 🎉
  • Renames writeable to writable within internal test code to be consistent with Node core naming conventions.

I tip my hat to @davidmarkclements here for doing all the heavy lifting:

Before

==========
OBJECT benchmark averages
BunyanObj average: 706.089ms
WinstonObj average: 519.757ms
BoleObj average: 291.980ms
LogLevelObject average: 556.841ms
PinoObj average: 279.025ms
PinoUnsafeObj average: 277.313ms
PinoExtremeObj average: 154.406ms
PinoUnsafeExtremeObj average: 151.695ms
==========

After

==========
OBJECT benchmark averages
BunyanObj average: 727.584ms
WinstonObj average: 446.947ms
BoleObj average: 309.041ms
LogLevelObject average: 577.650ms
PinoObj average: 282.819ms
PinoUnsafeObj average: 282.245ms
PinoExtremeObj average: 155.538ms
PinoUnsafeExtremeObj average: 148.020ms
==========

That's almost a 20% gain on that benchmark. 💯

Copy link
Contributor

@DABH DABH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Merge this in!

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