The source code for my MySQL glue is here:
https://github.com/mschwartz/SilkJS/blob/master/mysql.cpp

at about line 571, is my function for creating the JavaScript array of
objects in C++ code.  I'm not sure why my code would be any slower
than a C++ implementation of JSON.parse().  In fact, making the
string, then parsing it would be adding steps.


at about line 487, is my function for generating the JSON string.

There is a significant measurable difference in performance between
just making the array in C++ and using eval().  Using eval() is WAY
faster.

The reason I implemented the JSON method is from reading various
messages about how from within JavaScript context, the creation of
arrays, object, etc., is inline and faster...


On Dec 8, 6:51 am, Sven Panne <[email protected]> wrote:
> Ooops, the first URL should have 
> beenhttp://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/...,
> sorry...
>
>
>
>
>
>
>
> On Thu, Dec 8, 2011 at 15:50, Sven Panne <[email protected]> wrote:
> > v8's JSON parser is written almost completely in C++, with no eval
> > involved:
>
> >http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/...
>
> > There is some JavaScript glue around it (plus the code for stringify) here:
>
> >http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/...
>
> > Cheers,
> >    S.
>
> > On Thu, Dec 8, 2011 at 15:06, mykes <[email protected]> wrote:
>
> >> Maybe the built-in JSON object in V8 is not the same as crocker's
> >> implementation?
>
> >> On Dec 8, 5:45 am, Stephan Beal <[email protected]> wrote:
> >> > On Thu, Dec 8, 2011 at 2:35 PM, Rico Wind <[email protected]> wrote:
> >> > > Try to use JSON.parse instead of eval
>
> >> > Crockford's impl of JSON.parse() simply verifies the data intensively
> >> > before running eval() on it to do the real parsing. i.e. in that
> >> particular
> >> > implementation calling JSON.parse() cannot possibly be faster than
> >> simply
> >> > using eval.
>
> >> >https://github.com/douglascrockford/JSON-js/blob/master/json2.js
>
> >> > // In the third stage we use the eval function to compile the text into
> >> a
> >> > // JavaScript structure. The '{' operator is subject to a syntactic
> >> ambiguity
> >> > // in JavaScript: it can begin a block or an object literal. We wrap
> >> the text
> >> > // in parens to eliminate the ambiguity.
>
> >> >                 j = eval('(' + text + ')');
>
> >> > --
> >> > ----- stephan bealhttp://wanderinghorse.net/home/stephan/
>
> >> --
> >> v8-users mailing list
> >> [email protected]
> >>http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to