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
<div id="nochildren">
</div>
function steelToe(object) {
function _steelToe(property) {
if (object && property) {
return steelToe(object[property]);
} else {
return property ? steelToe() : object;
}
}
_steelToe.set = function(traversalChain, value) {
var keys = traversalChain.split('.'),
object = _steelToe;
for (var i = 0; i < keys.length; i++) {
if (!object()[keys[i]]) {
object()[keys[i]] = {};
}
if (i == keys.length - 1) {
object()[keys[i]] = value;
}
object = object(keys[i]);
}
return value;
}
_steelToe.walk = function(traversalChain) {
if (traversalChain) {
var keys = traversalChain.split('.'),
returnObject = _steelToe,
i;
for (i = 0; i < keys.length; i += 1) {
returnObject = returnObject(keys[i])
}
return returnObject();
} else {
return _steelToe();
}
};
return _steelToe;
};
var template = '{"father": {"info": {"name": "Brad1", "children": "' + Math.round(Math.random() * 11) + '"}}}',
families = [],
obj, nochildren = 0;
for (var i = 0; i < 100000; i++) {
obj = JSON.parse(template);
if (Math.round(Math.random() * 11) == Math.round(Math.random() * 11)) {
delete obj.children;
nochildren++;
}
families.push(obj);
};
document.getElementById('nochildren').innerHTML = 'nochildren times:' + nochildren;
Ready to run.
Test | Ops/sec | |
---|---|---|
check |
| ready |
SteelToe |
| ready |
try-catch |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.