JSON 3
JavaScript performance comparison
Info
This test benchmarks JSON 3 against other JSON implementations.
The following implementations support parsing and serializing:
- JSON 3: Uses a modified, character-based recursive descent parser.
- JSON 2: Uses
evaland a series of validation RegExps.
The following implementations only support parsing:
json-parse: Uses a character-based recursive descent parser.json-parse-state: Uses a state machine parser.json-sans-eval: Uses a non-validating RegExp.evalJSON: Uses a RegExp-based recursive descent parser.
Preparation code
<!-- JSON 3 v3.2.2 -->
<script>
// Disable the native JSON implementation.
this.JSON = null;
</script>
<script src="http://bestiejs.github.com/json3/lib/json3.min.js"></script>
<!-- JSON 2 -->
<script>
// Set up JSON 2.
this.JSON3 = this.JSON;
this.JSON = null;
</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
<script>
this.JSON2 = this.JSON;
this.JSON = null;
</script>
<!-- `json-parse-state` (Crockford's state machine parser) -->
<script src="http://dl.dropbox.com/u/43343137/json_parse_state.js"></script>
<script>
// `json-parse` is exposed via the `json_parse` function as well.
this.json_parse_state = this.json_parse;
</script>
<!-- `json-parse` (Crockford's recursive descent parser) -->
<script src="http://dl.dropbox.com/u/43343137/json_parse.js"></script>
<!-- Mike Samuel's `json-sans-eval` -->
<script src="http://json-sans-eval.googlecode.com/svn/trunk/src/json_sans_eval.js"></script>
<!-- Asen Bozhilov's `evalJSON` -->
<script src="http://dl.dropbox.com/u/43343137/evalJSON.js"></script>
<script>
Benchmark.prototype.setup = function() {
var value = '{"kitcambridge":"Kit","contributors":{"jdalton":"John-David","mathias":"Mathias"},"list":[1,2,3],"number":5,"date":"2012-04-25T14:08:36.879Z","boolean":true,"nil":null}';
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
JSON 3: parse |
|
pending… |
JSON 2: parse |
|
pending… |
json-parse-state |
|
pending… |
json-parse |
|
pending… |
json-sans-eval |
|
pending… |
evalJSON |
|
pending… |
eval |
|
pending… |
strict dojo eval |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Kit Cambridge
- Revision 2: published
- Revision 3: published by Mike McCaughan
- Revision 4: published
- Revision 5: published
- Revision 12: published
- Revision 14: published
- Revision 15: published by 3E
- Revision 17: published
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published
0 comments