bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

JSON3 Performance #7

Closed ScottHamper closed 12 years ago

ScottHamper commented 12 years ago

README.md states:
"Informal benchmarks have shown that JSON 3 is slower than Crockford's recursive descent parser and Mike Samuel's json-sans-eval, but approximates the speed of the eval-based JSON 2 parser."

So I decided to write a JSPerf test to compare JSON3's parse method to that of JSON2's and Crockford's non-eval based implementations: http://jsperf.com/crockfords-json-libraries

It seems to be the case that JSON3 is actually about on par with Crockford's recursive descent parser, but significantly slower than his eval parser. Though, it's worth double checking my test setup, as I may have goofed something up when changing code around to avoid collisions between json2 and json3.

Not really an issue, but I thought you might find a more formal benchmark interesting.

ghost commented 12 years ago

Wow, thank you for doing that! The "informal benchmarks" were removed in 9bc735e90870975bff0dadd441b90f110a317866...they only ran on Node, and executed only one parse test. I posted a screenshot of the results, but they seem hardly representative (a 1.4 GHz Core 2 Duo Air isn't the best machine to run benchmarks on). I also compared Mike Samuel's json-sans-eval and @abozhilov's evalJSON.

Your setup looks solid. I'll go ahead and update README.md to be more accurate, and add a link to your jsPerf test case.

ScottHamper commented 12 years ago

Glad it was useful! I've gone ahead and updated the tests to include Mike Samuel's json_sans_eval and @abozhilov's evalJSON, http://jsperf.com/crockfords-json-libraries/2

For reference, I'm benchmarking on a 2.8 GHz Intel Xeon (I ran a test on Chrome, IE6, and IE7 - IE's were in a VM).