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="tra" class="test">a</div>
<div>
<span>
<b foo="bar">XD</b>
</span>
</div>
<script>
delete document.querySelectorAll
this.Q = function(a) {
function s(b, d) {
d = d || a;
if (d.getElementsByTagName && !/\W/.test(b)) return p(d.getElementsByTagName(b));
if (d[f] && /^\.[\w-]+/.test(b)) return p(d[f](b.slice(1)));
if (d[g] && c.test(b)) {
e = d[g](b.slice(1));
return e ? [e] : []
}
b = b.split(" ");
if (c.test(b[0])) {
e = a[g](b.shift().slice(1));
if (!e || !o(d, e)) return [];
d = e
}
var h = r(b.shift(), d),
i, j, k;
for (i in b) {
k = [];
for (j in h) l.apply(k, r(b[i], h[j]));
h = k
}
return h
}
function r(c, e) {
var i, j;
(j = b.exec(c)) ? (j = a[g](j[1]), i = j && o(j, e) ? [j] : [], c = c.replace(b, "")) : e[f] && (j = h.exec(c)) ? i = e[f](j[1]) : i = e.getElementsByTagName((j = d.exec(c)) ? (c = c.replace(d, ""), j[1]) : "*");
if (!c) return p(i);
for (var k in n) {
var l = n[k];
while (j = l[0].exec(c)) {
var m = j[1],
r = j[2],
s = j[3];
l[2] && (m = " " + m + " "), c = c.replace(l[0], ""), i = q(i, function(a) {
return l[1](a, m, r, s)
});
if (!c) return p(i)
}
}
return p(i)
}
function q(a, b) {
ret = [];
for (x = 0; x < a.length; x++)(!b || a[x] && b(a[x], x)) && ret.push(a[x]);
return ret
}
function p(a) {
return m.call(a, 0)
}
var b = /#([\w-]+)/,
c = /^#[\w-]+/,
d = /^([\w-\*]+)/,
f = "getElementsByClassName",
g = "getElementById",
h = /\.([\w-]+)/,
i = [],
j = {},
k = {},
l = i.push,
m = i.slice,
n = [
[d, function(a, b) {
return a.nodeName == b.toUpperCase()
}],
[h, function(a, b) {
return (" " + a.className + " ").indexOf(b) >= 0
},
1],
[/\[([\w-]+)(?:(.)=?([\w-]+))?\]/, function(a, b, c, d) {
attr = a.getAttribute(b);
if (!attr || !c) return attr;
var e = 0;
if (attr) switch (c) {
case "=":
e = attr == d;
break;
case "!":
e = attr != d;
break;
case "^":
e = (j[c + d] = j[c + d] || new RegExp("^" + d)).test(attr);
break;
case "*":
e = (j[c + d] = j[c + d] || new RegExp(d)).test(attr);
break;
case "$":
e = (j[c + d] = j[c + d] || new RegExp(d + "$")).test(attr)
} else e = 0;
return e
}]
];
a.isDoc = 1;
var o = a.createElement("div").contains ?
function(a, b) {
if (a.isDoc) return !0;
return a.contains(b)
} : function(a, b) {
if (a.isDoc) return !0;
while (b = b.parentNode) if (b == a) return !0;
return !1
};
return s
}(document)
/*!
* qwery.js - copyright @dedfat
* https://github.com/ded/qwery
* Follow our software http://twitter.com/dedfat
* MIT License
*/
/*!
* qwery.js - copyright @dedfat
* https://github.com/ded/qwery
* Follow our software http://twitter.com/dedfat
* MIT License
*/
!
function(a, b) {
function V(a, c) {
var d = typeof c == "string" ? V(c)[0] : c || b;
if (!d || !a) return [];
if (h = S(a, c, V)) return h;
return X(a, d)
}
function U(a) {
var b = [],
c, d;
label: for (c = 0; c < a.length; c++) {
for (d = 0; d < b.length; d++) if (b[d] == a[c]) continue label;
b[b.length] = a[c]
}
return b
}
function T(a) {
return a && a.nodeType && (a.nodeType == 1 || a.nodeType == 9)
}
function S(a, c, d) {
var e = typeof c == "string" ? d(c)[0] : c || b;
if (a === window || T(a)) return !c || a !== window && T(e) && W(a, e) ? [a] : [];
if (a && typeof a == "object" && isFinite(a.length)) return G(a);
if (h = a.match(w)) return (m = b.getElementById(h[1])) ? [m] : [];
if (h = a.match(y)) return G(e.getElementsByTagName(h[1]));
return !1
}
function R(a) {
var b = [],
c = [],
d, g, h = L.g(a) || L.s(a, a.split(B));
h = h.slice(0);
if (!h.length) return b;
b = O(h);
if (!h.length) return b;
for (e = 0, g = b.length, f = 0; e < g; e++) {
n = b[e], j = n;
for (d = h.length; d--;) z: while (j !== A && (j = j.parentNode)) if (p = N.apply(j, M(h[d]))) break z;p && (c[f++] = n)
}
return c
}
function Q(a, b, c) {
switch (a) {
case "=":
return b == c;
case "^=":
return b.match(K.g("^=" + c) || K.s("^=" + c, new RegExp("^" + P(c))));
case "$=":
return b.match(K.g("$=" + c) || K.s("$=" + c, new RegExp(P(c) + "$")));
case "*=":
return b.match(K.g(c) || K.s(c, new RegExp(P(c))));
case "~=":
return b.match(K.g("~=" + c) || K.s("~=" + c, new RegExp("(?:^|\\s+)" + P(c) + "(?:\\s+|$)")));
case "|=":
return b.match(K.g("|=" + c) || K.s("|=" + c, new RegExp("^" + P(c) + "(-|$)")))
}
return !1
}
function P(a) {
return J.g(a) || J.s(a, a.replace(C, "\\$1"))
}
function O(a) {
var c = [],
d = a.pop(),
e = M(d),
f = e[1] || "*",
g, i, j, k = a.length && (h = a[0].match(w)) ? b.getElementById(h[1]) : b;
if (!k) return c;
j = k.getElementsByTagName(f);
for (g = 0, i = j.length; g < i; g++) m = j[g], (r = N.apply(m, e)) && c.push(r);
return c
}
function N(a, b, c, e, f, g, h) {
var j, k, l;
if (b && this.tagName.toLowerCase() !== b) return !1;
if (c && (j = c.match(u)) && j[1] !== this.id) return !1;
if (c && (q = c.match(v))) for (d = q.length; d--;) {
k = q[d].slice(1);
if (!(I.g(k) || I.s(k, new RegExp("(^|\\s+)" + k + "(\\s+|$)"))).test(this.className)) return !1
}
if (e && !h) {
i = this.attributes;
for (l in i) if (Object.prototype.hasOwnProperty.call(i, l) && (i[l].name || l) == f) return this
}
if (e && !Q(g, this.getAttribute(f) || "", h)) return !1;
return this
}
function M(a) {
return a.match(F)
}
function G(a) {
k = [];
for (d = 0, o = a.length; d < o; d++) k[d] = a[d];
return k
}
var c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u = /#([\w\-]+)/,
v = /\.[\w\-]+/g,
w = /^#([\w\-]+$)/,
x = /^\.([\w\-]+)$/,
y = /^([\w\-]+)$/,
z = /^([\w]+)?\.([\w\-]+)$/,
A = b.documentElement,
B = /\s(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\])/,
C = /([.*+?\^=!:${}()|\[\]\/\\])/g,
D = /^([a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,
E = /\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,
F = new RegExp(D.source + "(" + E.source + ")?"),
H = function() {
this.c = {}
};
H.prototype = {
g: function(a) {
return this.c[a] || undefined
},
s: function(a, b) {
this.c[a] = b;
return b
}
};
var I = new H,
J = new H,
K = new H,
L = new H,
W = "compareDocumentPosition" in A ?
function(a, b) {
return (b.compareDocumentPosition(a) & 16) == 16
} : "contains" in A ?
function(a, c) {
c = c == b || c == window ? A : c;
return c !== a && c.contains(a)
} : function(a, b) {
while (a = a.parentNode) if (a === b) return 1;
return 0
},
X = b.querySelector && b.querySelectorAll ?
function(a, c) {
if (b.getElementsByClassName && (h = a.match(x))) return G(c.getElementsByClassName(h[1]));
return G(c.querySelectorAll(a))
} : function(a, c) {
var d = [],
f, i = [],
j;
if (h = a.match(z)) {
s = c.getElementsByTagName(h[1] || "*"), k = I.g(h[2]) || I.s(h[2], new RegExp("(^|\\s+)" + h[2] + "(\\s+|$)"));
for (j = 0, g = s.length, e = 0; j < g; j++) k.test(s[j].className) && (d[e++] = s[j]);
return d
}
for (j = 0, s = a.split(","), g = s.length; j < g; j++) i[j] = R(s[j]);
for (j = 0, g = i.length; j < g && (f = i[j]); j++) {
var l = f;
if (c !== b) {
l = [];
for (e = 0, h = f.length; e < h && (element = f[e]); e++) W(element, c) && l.push(element)
}
d = d.concat(l)
}
return U(d)
};
V.uniq = U;
var Y = a.qwery;
V.noConflict = function() {
a.qwery = Y;
return this
}, a.qwery = V
}(this, document)
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Mine |
| ready |
qwery |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.