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>
// Created in a closure to simulate how Dojo 1.6's eval is defined.
// All variables in the closure are the same name as the variables in
// the closure dojo.eval is defined in for 1.6.
var eval16 = (function() {
var cn = ["assert", "count", "debug", "dir", "dirxml", "error", "group", "groupEnd", "info", "profile", "profileEnd", "time", "timeEnd", "trace", "warn", "log"],
i = 0,
tn;
// dojo alias
var d = {
_scopeName: "dojo",
_scopePrefix: "",
_scopePrefixArgs: "",
_scopeSuffix: "",
_scopeMap: {},
_scopeMapRev: {}
};
d._scopeArgs = [];
d.global = this;
d.config = {
isDebug: false,
debugAtAllCosts: false,
};
d.locale = "";
d.version = {};
// djConfig
var cfg = {},
c;
var rev = "$Rev$".match(/\d+/);
var extraNames, extraLen, empty = {};
for (i in {
toString: 1
}) {
extraNames = [];
break;
}
d._extraNames = extraNames = extraNames || ["hasOwnProperty", "valueOf", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString", "toString", "constructor"];
extraLen = extraNames.length;
d._mixin = function() {};
d.mixin = function() {};
d._getProp = function() {};
d.setObject = function() {};
d.getObject = function() {};
d.exists = function() {};
d["eval"] = function(text) {
return d.global.eval ? d.global.eval(text) : eval(text);
};
d.deprecated = d.experimental = function() {};
d.Deferred = function() {};
d.Color = function() {};
d.indexOf = function() {};
d.forEach = function() {};
d.map = function() {};
d.every = function() {};
d.some = function() {};
return d["eval"];
})();
var eval17 = new Function("text", "return eval(text);");
// Defined in the global scope so it's a lot
// like eval17
var eval17New = function(text) {
return eval(text);
};
var eval17Scoped = (new Function("eval", "return function(){ return eval(arguments[0]); };"))(eval);
var evalFunc = function(text) {
return (Function(text)());
};
var dojoEval; // this will get set in the tests
// Note that I have to suffix these variables with '1'
// because 'c', 'd', and 'i' will be shadowed in the
// 1.6 test case
var a1 = 'dojoEval(b1);',
b1 = 'dojoEval(c1);',
c1 = 'dojoEval(d1);',
d1 = 'dojoEval(e1);',
e1 = 'dojoEval(f1);',
f1 = 'dojoEval(g1);',
g1 = 'dojoEval(h1);',
h1 = 'dojoEval(i1);',
i1 = 'dojoEval(j1);',
j1 = 'dojoEval(k1);',
k1 = 'dojoEval(l1);',
l1 = 'dojoEval(m1);',
m1 = 'dojoEval(n1);',
n1 = 'dojoEval(o1);',
o1 = 'dojoEval(p1);',
p1 = 'dojoEval(q1);',
q1 = 'dojoEval(r1);',
r1 = 'dojoEval(s1);',
s1 = 'dojoEval(t1);',
t1 = 'dojoEval(u1);',
u1 = 'dojoEval(v1);',
v1 = 'dojoEval(w1);',
w1 = 'dojoEval(x1);',
x1 = 'dojoEval(y1);',
y1 = 'dojoEval(z1);',
z1 = 'dojoEval("1+2+3+4*200");';
ui.benchmarks[0].setup = function() {
window.dojoEval = window.eval16;
if (dojoEval(a1) != 806) {
throw new Error;
}
};
ui.benchmarks[1].setup = function() {
window.dojoEval = window.eval17;
if (dojoEval(a1) != 806) {
throw new Error;
}
};
ui.benchmarks[2].setup = function() {
window.dojoEval = window.eval17New;
if (dojoEval(a1) != 806) {
throw new Error;
}
};
ui.benchmarks[3].setup = function() {
window.dojoEval = window.eval17Scoped;
if (dojoEval(a1) != 806) {
throw new Error;
}
};
ui.benchmarks[4].setup = function() {
window.dojoEval = window.evalFunc;
// Using Function() the way it's being used doesn't
// return the result of the eval so we're not
// checking it
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
1.6 eval |
| ready |
1.7 eval |
| ready |
1.7 function expression |
| ready |
1.7 eval scoped |
| ready |
Func eval |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.