Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
spread vs for loop vs array push vs slice vs Array.from
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0
Browser:
Firefox 121
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
spread
22409226.0 Ops/sec
for loop
53141388.0 Ops/sec
for loop (array push)
67810976.0 Ops/sec
slice
42445344.0 Ops/sec
Array.from
15778835.0 Ops/sec
Script Preparation code:
var obj = [ { type: "fixedCost", description: { content: "<p><br></p>", widgets: {}, tokens: [ { type: "block", subType: "paragraph", }, { type: "inline", subType: "text", content: "TMS and ESS Licences", style: {}, }, ], }, quantity: 1, discount: { enabled: false, type: "percent", units: 0, }, rate: { unit: "Employee Licence", rate: 4.05, }, isTaxExempt: false, interactive: { isOptional: false, isOptionalSelected: false, isQuantityOptional: false, quantityRange: { min: 0, max: 0, }, isOptionalQuantity: false, }, currency: "GBP", id: "k55w3lGzGM4", }, { type: "fixedCost", description: { content: "<p><br></p>", widgets: {}, tokens: [ { type: "block", subType: "paragraph", }, { type: "inline", subType: "text", content: "Biometric Clock", }, ], }, quantity: 5, discount: { enabled: false, type: "percent", units: 0, }, rate: { unit: "Unit", rate: 1500, }, isTaxExempt: false, interactive: { isOptional: true, isOptionalSelected: false, isQuantityOptional: true, quantityRange: { min: 0, max: 5, }, }, currency: "GBP", id: "iQWwrO6qLew", }, { type: "fixedCost", description: { content: "<p><br></p>", widgets: {}, tokens: [ { subType: "paragraph", type: "block", }, { content: "Proximity Clock", subType: "text", type: "inline", }, ], }, quantity: 5, discount: { enabled: false, type: "percent", units: 0, }, rate: { unit: "Unit", rate: 1500, }, isTaxExempt: false, interactive: { isOptional: true, isOptionalSelected: false, isQuantityOptional: true, quantityRange: { min: 0, max: 100, }, }, currency: "GBP", id: "u0eMdVcAx1U", }, { type: "text", description: { content: "<p><br></p>", widgets: {}, tokens: [ { type: "block", subType: "paragraph", }, { type: "inline", subType: "text", content: "T&A Clocking Terminals", style: {}, }, ], }, interactive: { isOptional: false, isOptionalSelected: false, }, id: "dPVSGJMm97g", }, { type: "fixedCost", description: { content: "<p><br></p>", widgets: {}, tokens: [ { type: "block", subType: "paragraph", }, { type: "inline", subType: "text", content: "MF900 Stainless Steel T&A/Muster Point (UK Only) (Reader Required - To be Identified from External Readers)", style: {}, }, ], }, quantity: 1, discount: { enabled: false, type: "percent", units: 0, }, rate: { unit: "Unit", rate: 1750, }, isTaxExempt: false, interactive: { isOptional: false, isOptionalSelected: false, isQuantityOptional: false, quantityRange: { min: 0, max: 0, }, isOptionalQuantity: false, }, currency: "GBP", id: "BCLCCimoZ6M", }, { type: "fixedCost", description: { content: "<p><br></p>", widgets: {}, tokens: [ { type: "block", subType: "paragraph", }, { type: "inline", subType: "text", content: "MF901 Stainless Steel T&A/Muster Point - PoE - (Beta Test Sites Only) (Reader Required - To be Identified from External Readers)", style: {}, }, ], }, quantity: 1, discount: { enabled: false, type: "percent", units: 0, }, rate: { unit: "Unit", rate: 1750, }, isTaxExempt: false, interactive: { isOptional: false, isOptionalSelected: false, isQuantityOptional: false, quantityRange: { min: 0, max: 0, }, isOptionalQuantity: false, }, currency: "GBP", id: "AOqDHpIIeAI", }, ];
Tests:
spread
let newObj = [...obj]
for loop
let newObj = [] for(let i=0; i<obj.length; i++) { newObj[i] = obj[i] }
for loop (array push)
let newObj = [] for(let i=0; i<obj.length; i++) { newObj.push(obj[i]) }
slice
let newArr = obj.slice();
Array.from
let newArr = Array.from(obj);