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

Publishing Basic Performance Metrics Would be Helpful #239

Open
machineghost opened this issue Sep 16, 2020 · 4 comments
Open

Publishing Basic Performance Metrics Would be Helpful #239

machineghost opened this issue Sep 16, 2020 · 4 comments
Assignees

Comments

@machineghost
Copy link

machineghost commented Sep 16, 2020

One of the biggest arguments against adopting JSON5 would be that "it will make serializing/parsing meaningfully slower".

That argument could easily be eliminated (or at least contextualized) with some basic metrics. It would be so helpful if the website had even a single simple chart, which just showed the performance scaling of parsing/serializing a basic example (eg. the package.json of a popular library like Express or React), in both JSON5, and with native JSON.parse/stringify methods.

If you could show other interesting details, like whether performance changes at all when you use JSON5 features (vs. just using it to parse JSON1), that'd be great too ...

... but really all that's needed for "MVP" status here is just any metrics, even extremely basic and simple ones.

@myhub
Copy link

myhub commented Sep 30, 2020

I also notice that json5 parser is much slow
So I need to cache the results and load from cache next time to get a better speed

@machineghost
Copy link
Author

machineghost commented Sep 30, 2020

Well, however you do it, if you want to be successful I think you need to publish some metrics at some point. It's ok if JSON5 is slower, as long as:

A) people know how much, so they can make an educated decision when adopting it, and

B) you're working to make it faster :-)

@jordanbtucker
Copy link
Member

jordanbtucker commented Oct 12, 2020

What is the use case for JSON5 to be comparable to JSON as far as performance? Keep in mind that JSON5 is JSON for Humans, not something to replace JSON.

@Gerrit0
Copy link

Gerrit0 commented Sep 5, 2021

Here's a graph that I find rather compelling. TypeDoc is a documentation generator. It does quite a few things... but part of it's process is getting themes to highlight code blocks. The highlighter that we use (Shiki) uses json5 to load theme descriptions... this should really be a negligible amount of time in the documentation process, especially considering that TypeDoc runs its input through the TypeScript compiler, which does a lot more work.

However, when benchmarking, 27% of TypeDoc's runtime is spent in json5, parsing themes. This really ought to be at most 3%, and probably even less than 1%, judging simply based on the amount of data that TypeScript consumes compared to json5. It looks like #233 should help significantly reduce this.

JSON5 might have been intended for humans, but it is not only being used by humans.

(The light blue parse function on the lower left is json5 - Shiki bundles its dependencies)

image

Edit: I experimentally replaced JSON5 with jsonc-parser, since JSON5 specific features didn't seem to be used, this immediately cut down Shiki's parse time to 7.4%. Maybe 1% was too ambitious... but 27% is still way slower.

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

No branches or pull requests

4 participants