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
function generateSalesChunk(salesCount) {
const allKeys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'];
return Array.from({ length: salesCount }, () => {
const numKeys = Math.floor(Math.random() * 7) + 2;
const selectedKeys = allKeys
.sort(() => Math.random() - 0.5)
.slice(0, numKeys);
return Object.fromEntries(
selectedKeys.map(key => {
const valueType = Math.floor(Math.random() * 4);
const value = [
() => Math.floor(Math.random() * 1000),
() => `value_${Math.random().toString(36).substring(7)}`,
() => Math.random() > 0.5,
() => Math.random() * 100
][valueType]();
return [key, value];
})
);
});
}
const chunk = generateSalesChunk(500)Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Iterate and add | | ready |
| flatMap construct | | ready |
| no inner loop | | ready |
| Object assign | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.