JSONH
JavaScript performance comparison
Info
JSONH is an Homogeneous Collections Compressor which aim is to pack/unpack over HTTP requests.
Please read the related post to know more.
Preparation code
<script>
var StaticJSONP = {
notify: function(uid, dummyData) {
window.dummyData = dummyData;
}
};
"JSON" in this || document.write('<','script src="http://www.3site.eu/examples/json.hpack/test/json2.js">','<','/script>');
document.write([
'<','script src="http://www.3site.eu/examples/json.hpack/test/dummy.js">','<','/script>',
'<','script src="http://www.3site.eu/examples/json.hpack/test/JSONH.js">','<','/script>',
'<','script src="http://www.3site.eu/examples/json.hpack/test/JSONHF.js">','<','/script>'
].join(""));
function unpack2(arr){
// for old [1,"a","A","B"] format
typeof arr[0] === "number" && arr.unshift(arr.splice(0,arr.shift()));
var keys = arr.shift(), klen = keys.length, pos = klen-1;
eval('while((pos-='+pos+')<'+(arr.length/klen)+')arr.splice(pos,'+klen+',{"'+keys.join('":arr[pos++],"')+'":arr[pos++]})');
return arr;
}
function unpack3(arr){
// for old [1,"a","A","B"] format
typeof arr[0] === "number" && arr.unshift(arr.splice(0,arr.shift()));
var keys = arr.shift(), klen = keys.length, pos = klen-1;
new Function("arr","pos",'while((pos-='+pos+')<'+(arr.length/klen)+')arr.splice(pos,'+klen+',{"'+keys.join('":arr[pos++],"')+'":arr[pos++]})')(arr,pos);
return arr;
}
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
JSON.stringify |
|
pending… |
JSONH.stringify |
|
pending… |
JSONH(Flat).stringify |
|
pending… |
JSON.parse |
|
pending… |
JSONH.parse |
|
pending… |
JSONH(Flat).parse |
|
pending… |
JSONH.parse2 |
|
pending… |
JSONH.parse3 |
|
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 WebReflection
- Revision 2: published by WebReflection
- Revision 3: published by WebReflection
- Revision 4: published
- Revision 5: published
- Revision 6: published
0 comments