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
const functionalPathToString = path => {
const matches = path.toString().split("=>");
const fullStringPath = matches[1]
.trim().replace(/[()]/g, "");
const pointIndex = fullStringPath.indexOf(".");
return pointIndex === -1
? ""
: fullStringPath.substring(pointIndex + 1);
};
const resolveAccess = p => p.replace(/\.\[/g, "[");
const normalizePart = p => (
typeof p === "number"
|| !isNaN(parseFloat(p)) ? `[${p}]` : p
);
const pathToStringArray = path => {
const parts = [];
const pathProxy = new Proxy({}, {
get(target, prop) {
parts.push(prop);
return pathProxy;
}
});
path(pathProxy);
return parts;
}
const pathToStringNew = path => (
resolveAccess(pathToStringArray(path).join("."))
);
Ready to run.
Test | Ops/sec | |
---|---|---|
pathToStringNew |
| ready |
functionalPathToString |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.