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 p = {
single1: "one",
many2: ["two", "th?e e"],
many0: [],
single0: "",
many3: ["a", "b", "c"],
"w t f": ["ikr", "lol"],
num: 1.23,
zero: 0,
bool1t: true,
bool1f: false,
bool2: [true, false]
};
const obj2qs_arr = (obj) => {
return Object.entries(obj).reduce((rv, [key, val]) => {
if (val.length > 0 || ["number", "boolean"].indexOf(typeof val) !== -1) {
rv.push((Array.isArray(val) ? val : [val]).map(
v => `${encodeURIComponent(key)}=${encodeURIComponent(v)}`
).join("&"))
}
return rv;
}, []).join("&")
};
const obj2qs_str = (obj) => {
return Object.entries(obj).reduce((rv,[key,val])=>{
console.warn( typeof val)
if(val.length > 0 || ["number","boolean"].indexOf(typeof val) !== -1 ){
rv += (rv.length > 0 ? "&" : "")
+ (Array.isArray(val) ? val : [val]).map(
v=>`${encodeURIComponent(key)}=${encodeURIComponent(v)}`
).join("&");
}
return rv;
},"")
};
Ready to run.
Test | Ops/sec | |
---|---|---|
array |
| ready |
str |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.