Hi Joran, The benchmarking method looks okay to me, and those results are about what I'd expect at the moment. For one thing Rhino is simply a slower engine than either of the other two in general. However, I do think there's room for improvement in the performance, especially for the parsing code. It would probably be best to profile it to see what's actually taking up the time, but I suspect the fact that I'm using regular expressions to tokenise the input might be a part of it. That could be replaced with custom lexing code, at the cost of a little more complexity though.
In any case, not a lot of thought has really been put into the performance of the JSON methods so far. I've mostly just wanted to make sure they're correct, as my main focus is to bring Rhino closer to EcmaScript 5 compliance. Is it too slow for your purposes? It should still be significantly faster than using the json2.js implementation via javascript. Actually the other proposed project for Rhino for the summer of code this year was working on general performance optimisations for the Rhino engine. That's something I'd like to see too. https://wiki.mozilla.org/Community:SummerOfCode09#Rhino Cheers, Raphael On Aug 8, 6:37 pm, Joran <[email protected]> wrote: > Hi Raphael, > Since the announcement of the new native JSON object for Rhino, I've > done some naïve testing on Rhino, TraceMonkey and V8, using two > simple > functions: > > var testparse = function(string) { var start = new Date().getTime(); > JSON.parse(string); return new Date().getTime() - start; }; > > var teststringify = function(object) { var start = new Date().getTime > (); JSON.stringify(object); return new Date().getTime() - start; }; > > 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've been running the functions about 20 times at a time on > each platform, a couple of times each over the last week, on a MacBook > Pro, and have found the following consistent averages: > > JSON.parse: > Rhino: 640ms > TraceMonkey: 44ms > V8: 27ms > > JSON.stringify: > Rhino: 140ms > V8: 70ms > TraceMonkey: 44ms > > Is my method okay? Are these results to be expected? _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
