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
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js"></script>
var data = [];
var MAX = 100000;
for (var i = 0; i < MAX; i++) {
data.push({
id: i,
nested: {
id: i
}
});
}
getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
var p, i = 0;
while(context && (p = parts[i++])){
context = (p in context ? context[p] : (create ? context[p] = {} : undefined));
}
return context; // mixed
}
getPropFunc = function(prop){
var parts, p, i = 0, f = "";
parts = prop.split(".");
for (var i = 0; i < parts.length; i++) {
var p = parts[i];
f += "['" + p + "']";
}
// f = new Function("o", "return o" + f);
f = eval("(function(o){return o" + f + "})");
return f;
}
idFunc = getPropFunc("id");
nestedIdFunc = getPropFunc("nested.id");
Ready to run.
Test | Ops/sec | |
---|---|---|
lang.getObject |
| ready |
direct [] access |
| ready |
getProp |
| ready |
getPropFunc |
| ready |
getPropFunc nested |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.