Curious, since 27ms is kinda low (and risks overhead/timecounting
inaccuracy), have you tried doing the JSON commands multiple times inside
your benchmark loop?

i.e.

var testparse = function(string,testcount) {
  var start = new Date().getTime();
  for (var i=0;i<testcount;i++) {
    JSON.parse(string);
  }
  return new Date().getTime() - start;
};

var teststringify = function(object,testcount) {
  var start = new Date().getTime();
  for (var i=0;i<testcount;i++) {
    JSON.stringify(object);
  }
  return new Date().getTime() - start;
};

Also, trying with higher numbers of iterations on smaller JSON strings may
help give a better "real-world" performance metric. I'm guessing most json
strings are more on the order of 10kb rather than 650kb.

Marcello



On Wed, Aug 12, 2009 at 7:44 AM, Joran <[email protected]> wrote:

> Thanks Hannes. This is great.
>
> After some quick playing, and using the same testparse and
> teststringify functions described above, here are some results. For
> "object", I used an array of 2082 objects. For "string", I used the
> JSON representation of "object". The length of "string" is about
> 650kb. I didn't try anything larger than that.
>
> JSON.parse:
> Rhino (before Hannes' patch): 640ms
> Rhino (after Hannes' patch): 90ms
> TraceMonkey: 44ms
> V8: 27ms
>
> JSON.stringify:
> Rhino (before Hannes' patch): 140ms
> Rhino (after Hannes' patch): 165ms
> V8: 70ms
> TraceMonkey: 44ms
>
> Thanks again, this will mean I also won't have to put a parsed-object
> cache in front of my key-value store (Tokyo Tyrant).
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to