|
@mathias | |||||
|
🚀 For large JSON-compatible objects, JSON.parse is faster than JS object literals.
➡️ True for all browser JavaScript engines!
➡️ Speed-ups from 1.2× to 2×
🎥 My #ChromiumDevSummit lightning talk explains why: youtube.com/watch?v=ff4fgQ…
|
||||||
|
||||||
|
nissy
@nissy_nd
|
25. stu |
|
Thank you for introducing github.com/nd-02110114/ba…
Feedback is welcome from everyone 👍
|
||
|
|
||
|
Mathias Bynens
@mathias
|
25. stu |
|
Thank you for creating the plugin!
|
||
|
|
||
|
Alexey Udivankin
@allx
|
26. stu |
|
Is there a jsperf (or similar repro) for that? Tried with ±200kb serialised redux state from real APP and JSON.parse appeared to be a bit (20% to none) slower. Also does this trick make sense when all the keys in object literal are quoted?
|
||
|
|
||
|
Mathias Bynens
@mathias
|
26. stu |
|
Did you watch the video? We point to the benchmark on GitHub around the 04:58 mark: youtube.com/watch?v=ff4fgQ…
|
||
|
|
||
|
Andrea Bogazzi
@AndreaBogazzi
|
23. stu |
|
i tried a couple of time with my 2.8 megs json object did not manage to see an improvement in my flame graph. Every time someone tweets this i go and try again.
|
||
|
|
||
|
Mathias Bynens
@mathias
|
23. stu |
|
How are you measuring this exactly? Have you tried running our benchmark with your data?
|
||
|
|
||
|
Leonardo Cruz
@llimacruz
|
23. stu |
|
That's Nice! Could I benefit of this on node/express receiving a massive payload in a post?
|
||
|
|
||
|
Andrea Bogazzi
@AndreaBogazzi
|
25. stu |
|
I may be wrong but the payload from a request is already a string and express apps are probably just json-parsing it. So you are already done.
|
||
|
|
||
|
Rob Palmer
@robpalmer2
|
26. stu |
|
Does this JSON.parse optimization offer any benefit once code caching kicks in?
It seems to reduce the large parse cost in favour of slightly greater execution cost. But when code caching, JS parsing is almost free, whereas execution cost still matters.
|
||
|
|
||
|
Mathias Bynens
@mathias
|
26. stu |
|
Did you see the benchmark referenced in the talk? It includes warm load tests: github.com/GoogleChromeLa… cc @leszekswirski @tverwaes for code caching insights specifically
|
||
|
|
||