jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Checking different JSON compression libs and techniques
<script src="//raw.github.com/msgpack/msgpack-javascript/master/msgpack.js">
</script>
<script src="//raw.github.com/nmrugg/LZMA-JS/master/src/lzma.js"></script>
<script src="//raw.github.com/nmrugg/LZMA-JS/master/src/lzma_worker.js"></script>
<script src="//raw.github.com/WebReflection/JSONH/master/js/jsonh.js"></script>
<script src="//raw.github.com/BonsaiDen/BiSON.js/master/lib/bison.js"></script>
var json = [{
surname: 'Jones',
age: 15,
gender: 'Male',
id: 1
}, {
age: 15,
gender: 'Female',
id: 2,
surname: 'Adams'
}, {
age: 34,
gender: 'Female',
id: 3,
firstname: 'Sally'
}, {
age: 22,
gender: 'Male',
location: 'London'
}, {
surname: 'Turley',
age: 19,
gender: 'Male',
id: 8
}, {
age: 76,
gender: 'Female',
id: 2,
surname: 'Tempest'
}, {
age: 34,
gender: 'Female',
id: 3,
firstname: 'Sally'
}, {
age: 22,
gender: 'Male',
location: 'London'
}];
// create a new object and turn data into set of keys and their references
function pack(items) {
var data = {
k: [],
d: []
};
data.d = process(items, data.k, set);
return data;
}
// grab the references and return the key values
function unpack(items) {
return process(items.d, items.k, get);
}
// loop through a list and run a function on its keys and values
function process(items, keys, func) {
var list = [],
obj = {};
for (var i = 0; i < items.length; ++i) {
obj = {};
for (var item in items[i]) {
obj[func(item, keys)] = func(items[i][item], keys);
}
list.push(obj);
}
return list;
}
// set a key and return its index
function set(item, items) {
for (var i = 0; i < items.length; ++i) {
if (item == items[i]) {
return i;
}
}
items.push(item);
return items.length - 1;
}
// get a key value by its index
function get(item, items) {
return items[parseInt(item, 10)];
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Kim's Method |
| ready |
msgpack.js |
| ready |
LZMA |
| ready |
hpack.js |
| ready |
bison.js |
| ready |
JSON.stringify |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.