Test name | Executions per second |
---|---|
Access | 3502.8 Ops/sec |
Destruct | 3514.8 Ops/sec |
"use strict";
const testArray = [];
for (let i = 0; i < 100; i++) {
const obj = {
index: Math.ceil(Math.random() * 100),
foo: {
size: Math.ceil(Math.random() * 100),
color: `${Math.ceil(Math.random() * 255)} ${Math.ceil(Math.random() * 255)} ${Math.ceil(Math.random() * 255)}`
},
simpleObjs: []
};
for (let j = 0; j < 25; j++) {
const simpleObject = {
title: `${Math.ceil(Math.random() * 666)}`,
quantity: Math.ceil(Math.random() * 10),
description: `WOOW${Math.ceil(Math.random() * 100)}OWOWOWO${Math.ceil(Math.random() * 100)}WOW`
};
obj.simpleObjs.push(simpleObject);
}
testArray.push(obj);
}
testArray.sort((a, b) => {
if (a.index > b.index) {
return 1;
}
if (a.index < b.index) {
return -1;
}
return 0;
});
"use strict";
const testArray = [];
for (let i = 0; i < 100; i++) {
const obj = {
index: Math.ceil(Math.random() * 100),
foo: {
size: Math.ceil(Math.random() * 100),
color: `${Math.ceil(Math.random() * 255)} ${Math.ceil(Math.random() * 255)} ${Math.ceil(Math.random() * 255)}`
},
simpleObjs: []
};
for (let j = 0; j < 25; j++) {
const simpleObject = {
title: `${Math.ceil(Math.random() * 666)}`,
quantity: Math.ceil(Math.random() * 10),
description: `WOOW${Math.ceil(Math.random() * 100)}OWOWOWO${Math.ceil(Math.random() * 100)}WOW`
};
obj.simpleObjs.push(simpleObject);
}
testArray.push(obj);
}
testArray.sort(({ index: aIndex }, { index: bIndex }) => {
if (aIndex > bIndex) {
return 1;
}
if (aIndex < bIndex) {
return -1;
}
return 0;
});