In node/V8, from what I understand, JSON.parse is already delegated to 
another language, it's in (fairly) optimized C++ code.  What you're seeing 
in that benchmark (when comparing "C++" and "Javascript Node") is less the 
expense of parsing JSON and more the expense of creating heavy-weight, 
garbage collected, etc, Javascript objects, compared to much more 
light-weight native objects (which couldn't possibly be used by Javascript 
code, as they need to be wrapped in relatively expensive layers to be 
exposed).  If you look at an actual pure-Javascript JSON parser (e.g. 
json5), it's performance is going to be even worse =).

This does mean, however, if you're getting a bunch of JSON data, and 
distilling it into a relatively small amount of data, you may get a pretty 
significant speed-up by doing that in a native module (big JSON -> big 
native structure -> small JS structure instead of big JSON -> big JS 
structure -> small JS structure).  Of course, that's true of *any* data 
processing in node (or any interpreted language) - moving the CPU-intensive 
heavily lifting to optimized native code will give you a boost, it's just 
usually not worth the complexity of doing so.

On Wednesday, May 27, 2015 at 4:50:30 AM UTC-7, Alisson Cavalcante Agiani 
wrote:
>
> https://github.com/kostya/benchmarks/tree/master/json
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/edc01385-d805-4a12-8641-0930217e5219%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to