Skip to content

Use JSON.parse for parsing teambuilder tables#1714

Merged
Zarel merged 1 commit intosmogon:masterfrom
sugar700:use-json-parse-for-parsing-battle-teambuilder-table
Jan 23, 2021
Merged

Use JSON.parse for parsing teambuilder tables#1714
Zarel merged 1 commit intosmogon:masterfrom
sugar700:use-json-parse-for-parsing-battle-teambuilder-table

Conversation

@sugar700
Copy link
Copy Markdown
Contributor

@sugar700 sugar700 commented Jan 22, 2021

This optimizes JavaScript parsing performance. V8 developers recommend applying this optimization for objects of 10 kB or larger, see https://v8.dev/blog/cost-of-javascript-2019#json for more details. Teambuilder tables are 3.5 MBs which is much more than 10 kB.

I have tested this optimization, albeit I don't know whether I have done this correctly. Over multiple attempts, with this change or not, in Firefox, this reduces parsing time from 600ms to 500ms. In Chrome, this reduces parsing time from 200ms to 100ms.

This was inspired by https://blog.guillaume-gomez.fr/articles/2021-01-22+Performance+improvement+on+front-end+generated+by+rustdoc blog post specifically which talks about optimization of rustdoc frontend code, and that was one of optimizations that was done (rustdoc PR: rust-lang/rust#71250).

This optimizes JavaScript parsing performance. V8 developers
recommend applying this optimization for objects of 10 kB or
larger, see <https://v8.dev/blog/cost-of-javascript-2019#json>
for more details. Teambuilder tables are 3.5 MBs which is much
more than 10 kB.
@Zarel
Copy link
Copy Markdown
Member

Zarel commented Jan 23, 2021

Interesting!

@Zarel Zarel merged commit 0005f1f into smogon:master Jan 23, 2021
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.

2 participants