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
// ufo
function parseQuery(parametersString = "") {
const object = {};
if (parametersString[0] === "?") {
parametersString = parametersString.slice(1);
}
for (const parameter of parametersString.split("&")) {
const s = parameter.match(/([^=]+)=?(.*)/) || [];
if (s.length < 2) {
continue;
}
const key = decodeQueryKey(s[1]);
if (key === "__proto__" || key === "constructor") {
continue;
}
const value = decodeQueryValue(s[2] || "");
if (object[key] === undefined) {
object[key] = value;
} else if (Array.isArray(object[key])) {
(object[key]).push(value);
} else {
object[key] = [object[key], value];
}
}
return object;
}
const PLUS_RE = /\+/g;
function decodeQueryKey(text) {
return decode(text.replace(PLUS_RE, " "));
}
function decodeQueryValue(text) {
return decode(text.replace(PLUS_RE, " "));
}
function decode(text = "") {
try {
return decodeURIComponent("" + text);
} catch {
return "" + text;
}
}
// vite
const requestQuerySplitRE = /\?(?!.*[/|}])/
function parseRequest(id){
const [_, search] = id.split(requestQuerySplitRE, 2)
if (!search) {
return null
}
return Object.fromEntries(new URLSearchParams(search))
}
const workerRe = /(\?|&)worker(?:&|$)/
const urlRe = /(\?|&)url(?:&|$)/
const rawRe = /(\?|&)raw(?:&|$)/
// data
const urls = [
'/foo/bar.js',
'/foo/bar.js?worker',
'/foo/bar.js?url',
'/foo/bar.js?worker&url',
'/foo/bar.js?raw',
''
]
.join('__')
.repeat(100)
.split('__')
Ready to run.
Test | Ops/sec | |
---|---|---|
ufo |
| ready |
regex |
| ready |
parseRequest |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.