JSON speed
JavaScript performance comparison
Preparation code
<span id="uniqueId" data-json='{"first":"abc","second":"def","thrid":"ghi"}'>Yo, here I am world!</span>
<script>
Benchmark.prototype.setup = function() {
function parseJsonX(json) {
var parsedObj = {};
json = json.replace(/"|{|}/g,'').split(',');
for(var l=json.length, i=0;i<l;i++) {
var keyValue = json[i].split(':');
parsedObj[keyValue[0]] = keyValue[1];
}
return parsedObj;
};
function parseJsonNative(json) {
return JSON.parse(json);
};
function parseJsonEval(json) {
return eval('(' + json + ')');
};
};
</script>
Preparation code output
Yo, here I am world!
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
X-browser parsing |
|
pending… |
JSON parsing |
|
pending… |
JSON 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 Aksel Nordal
- Revision 2: published by test1
- Revision 3: published
0 comments